字符编码

JS 使用 UTF-16 使用 two byte

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

image.pngJS � Character Encodings - YouTubeopen in new window

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

String.fromCharCode(27721)
Last Updated:
Contributors: gongyi01