Merge pull request #1155 from aruseni/patch-11
[strings] Surrogate pairs S example
This commit is contained in:
commit
9ff9aae04d
1 changed files with 5 additions and 3 deletions
|
@ -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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue