我是靠谱客的博主 直率航空,这篇文章主要介绍html 反转义 c,js 对html 的转义与反转义,现在分享给大家,希望可以做个参考。

1. 项目中碰到html 编码为万国编码的情况下进行转义为html编码

d582eff4964c

转义为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

},

d582eff4964c

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

}

d582eff4964c

最后

以上就是直率航空最近收集整理的关于html 反转义 c,js 对html 的转义与反转义的全部内容,更多相关html内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(69)

评论列表共有 0 条评论

立即
投稿
返回
顶部