String.prototype.charCodeAt()
方法返回0到65535之间的整数,表示给定索引处的UTF-16代码单元
延伸:在node后端中使用 fs.readFile()其中有指定方式读取是 utf-8
const sendHtml = (path, response) => { let options = { encoding:"utf-8" } fs.readFile(path, options, (error, data) => { response.send(data) }) } const index = { method: "get", path: "/", func:(request, response) => { let path = "template/blog_index.html" sendHtml(path, response) } }
String.fromCharCode()
作用正好与charCodeAt 相反