Skip to content

字符编码

JS 使用 UTF-16 使用 two byte

js
const uint8arr = new TextEncoder().encode('Hi!')
console.log(uint8arr)
new TextDecoder('utf8').decode(uint8arr) // 'Hi!'

image.pngJS � Character Encodings - YouTube

js
let str = '汉'
str.charCodeAt(0) // 27721

String.fromCharCode(27721)