首页 > 其他 > 详细

字符串方法总结

时间:2019-11-10 12:52:11      阅读:72      评论:0      收藏:0      [点我收藏+]

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

 

字符串方法总结

原文:https://www.cnblogs.com/-constructor/p/11829152.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!