Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,2 @@
var s = "Hello, world!";
var byteCount = s.length * 2; // 26

View file

@ -0,0 +1,5 @@
a = '👩‍❤️‍👩'
Buffer.byteLength(a, 'utf16le'); // 16
Buffer.byteLength(a, 'utf8'); // 20
Buffer.byteLength(s, 'utf16le'); // 26
Buffer.byteLength(s, 'utf8'); // 13

View file

@ -0,0 +1,2 @@
(new TextEncoder().encode(a)).length; // 20
(new TextEncoder().encode(s)).length; // 13

View file

@ -0,0 +1,5 @@
var str1 = "Hello, world!";
var len1 = str1.length; // 13
var str2 = "\uD834\uDD2A"; // U+1D12A represented by a UTF-16 surrogate pair
var len2 = str2.length; // 2

View file

@ -0,0 +1 @@
[...str2].length // 1

View file

@ -0,0 +1 @@
[...new Intl.Segmenter().segment(a)].length; // 1

View file

@ -0,0 +1,21 @@
let
str='AöЖ€𝄞'
,countofcodeunits=str.length // 6
,cparr=[...str],
,countofcodepoints=cparr.length; // 5
{ let
count=0
for(let codepoint of str)
count++
countofcodepoints=count // 5
}
{ let
count=0,
it=str[Symbol.iterator]()
while(!it.next().done)
count++
countofcodepoints=count // 5
}
{ cparr=Array.from(str)
countofcodepoints=cparr.length // 5
}