Skip to content

Commit 0a7ded5

Browse files
authored
[strings] Surrogate pairs S example
1 parent 11e9d98 commit 0a7ded5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

1-js/05-data-types/03-string/article.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,12 @@ This provides great flexibility, but also an interesting problem: two characters
631631
For instance:
632632

633633
```js run
634-
alert( 'S\u0307\u0323' ); // Ṩ, S + dot above + dot below
635-
alert( 'S\u0323\u0307' ); // Ṩ, S + dot below + dot above
634+
let s1 = 'S\u0307\u0323'; // Ṩ, S + dot above + dot below
635+
let s2 = 'S\u0323\u0307'; // Ṩ, S + dot below + dot above
636636

637-
alert( 'S\u0307\u0323' == 'S\u0323\u0307' ); // false, different characters (?!)
637+
alert( `s1: ${s1}, s2: ${s2}` );
638+
639+
alert( s1 == s2 ); // false though the characters look identical (?!)
638640
```
639641

640642
To solve this, there exists a "unicode normalization" algorithm that brings each string to the single "normal" form.

0 commit comments

Comments
 (0)