字符串方法总结

时间:2019-11-10 12:07:25   收藏:0   阅读:104

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 相反

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!