码迷,mamicode.com
首页 > 其他好文 > 详细

字符串方法总结

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

标签:返回   方式   arc   error   ror   之间   rom   span   from   

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

 

字符串方法总结

标签:返回   方式   arc   error   ror   之间   rom   span   from   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!