Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to normalize string in javascript

// The normalize() method returns the Unicode Normalization Form of the string.

const name1 = 'u0041u006du00e9u006cu0069u0065';
const name2 = 'u0041u006du0065u0301u006cu0069u0065';

console.log(`${name1}, ${name2}`);
// expected output: "Amélie, Amélie"
console.log(name1 === name2);
// expected output: false
console.log(name1.length === name2.length);
// expected output: false

const name1NFC = name1.normalize('NFC');
const name2NFC = name2.normalize('NFC');

console.log(`${name1NFC}, ${name2NFC}`);
// expected output: "Amélie, Amélie"
console.log(name1NFC === name2NFC);
// expected output: true
console.log(name1NFC.length === name2NFC.length);
// expected output: true
Comment

PREVIOUS NEXT
Code Example
Javascript :: npm is not recognized 
Javascript :: javascript html append 
Javascript :: minify html using javascript 
Javascript :: mongodb mongoose push into nested array 
Javascript :: js math function that returns smallest value 
Javascript :: how to handle fetch errors 
Javascript :: js how to filter only real numbers from decimals 
Javascript :: how to use axios get 
Javascript :: object.entries 
Javascript :: html onchange call js function 
Javascript :: discord.js checking channel permissions 
Javascript :: sort in javascript array 
Javascript :: javascript redirect with extra url arguments 
Javascript :: how to make fake binary 
Javascript :: react compress image 
Javascript :: switch alert 
Javascript :: convert Float64Array to array in js 
Javascript :: duplicate elements of array multiple times 
Javascript :: how to send axios delete to the backend reactjs 
Javascript :: how to read a csv file in nodejs 
Javascript :: javascript remove element from object 
Javascript :: get value of hidden type field 
Javascript :: remove repetition 2d array javascript 
Javascript :: vue toggle boolean on click 
Javascript :: js object clear 
Javascript :: string.contains javascript 
Javascript :: remove object from array by name javascript 
Javascript :: how to convert string to sentence case in javascript 
Javascript :: unix to date in javascript 
Javascript :: debouncing 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =