Merge pull request #1155 from aruseni/patch-11

[strings] Surrogate pairs S example
This commit is contained in:
Ilya Kantor 2019-07-16 11:37:08 +03:00 committed by GitHub
commit 9ff9aae04d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -631,10 +631,12 @@ This provides great flexibility, but also an interesting problem: two characters
For instance: For instance:
```js run ```js run
alert( 'S\u0307\u0323' ); // Ṩ, S + dot above + dot below let s1 = 'S\u0307\u0323'; // Ṩ, S + dot above + dot below
alert( 'S\u0323\u0307' ); // Ṩ, S + dot below + dot above let s2 = 'S\u0323\u0307'; // Ṩ, S + dot below + dot above
alert( 'S\u0307\u0323' == 'S\u0323\u0307' ); // false, different characters (?!) alert( `s1: ${s1}, s2: ${s2}` );
alert( s1 == s2 ); // false though the characters look identical (?!)
``` ```
To solve this, there exists a "unicode normalization" algorithm that brings each string to the single "normal" form. To solve this, there exists a "unicode normalization" algorithm that brings each string to the single "normal" form.