Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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‎

Lines changed: 5 additions & 3 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /