1. 项目中碰到html 编码为万国编码的情况下进行转义为html编码
转义为html 编码
// 万国码转义为html编码
htmlDecodeByRegExp(str) {
var temp = ""
if (str.length == 0) return ""
temp = str.replace(/&/g, "&")
temp = temp.replace(/</g, "
temp = temp.replace(/>/g, ">")
temp = temp.replace(/ /g, " ")
temp = temp.replace(/'/g, "'")
temp = temp.replace(/"/g, """)
return temp
},
html 反转义
// html编码转义万国码
htmlEncodeByRegExp (str) {
var temp = ""
if (str.length == 0) return ""
temp = str.replace(/&/g, "&")
temp = temp.replace(/
temp = temp.replace(/>/g, ">")
temp = temp.replace(/s/g, " ")
temp = temp.replace(/'/g, "'")
temp = temp.replace(/"/g, """)
return temp
}
最后
以上就是直率航空最近收集整理的关于html 反转义 c,js 对html 的转义与反转义的全部内容,更多相关html内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复