小程序
小游戏
企业微信
微信支付
扫描小程序码分享
做 这样的 html 实体,该怎么解析呢?我用 wxParse 解析不了……
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
图标库么? 做 = \u20570
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
不是图标库,是我从别人网站拿来的数据,要进行渲染。
&#转\u
数字转hex
;去掉
谢谢,我试试
let reAndWell = /&
#/g;
let reNum = /\d{5}/g;
let reSemicolon = /;/g;
commentList.forEach(com => {
let result = com.commContent.replace(reAndWell,
'\\u'
).replace(reNum, num => {
return
num.toString(16);
});
com.commContent = result.replace(reSemicolon,
''
);
我是这样进行替换的,开发者工具能够看到替换后的代码。但是我在Unicode与中文互转工具中测试了几个,都不能转换成正常的汉字。能告诉我是哪里出了错吗?
Number(num).toString(16);
let unicode = result.replace(reSemicolon,
com.commContent = String(unicode);
console.log(com.commContent);
string.fromcharcode就好
第一次用 fromCharCode,问题解决了,非常感谢!
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
图标库么? 做 = \u20570
不是图标库,是我从别人网站拿来的数据,要进行渲染。
&#转\u
数字转hex
;去掉
谢谢,我试试
let reAndWell = /&
#/g;
let reNum = /\d{5}/g;
let reSemicolon = /;/g;
commentList.forEach(com => {
let result = com.commContent.replace(reAndWell,
'\\u'
).replace(reNum, num => {
return
num.toString(16);
});
com.commContent = result.replace(reSemicolon,
''
);
});
我是这样进行替换的,开发者工具能够看到替换后的代码。![]()
但是我在Unicode与中文互转工具中测试了几个,都不能转换成正常的汉字。能告诉我是哪里出了错吗?
let reAndWell = /&
#/g;
let reNum = /\d{5}/g;
let reSemicolon = /;/g;
commentList.forEach(com => {
let result = com.commContent.replace(reAndWell,
'\\u'
).replace(reNum, num => {
return
Number(num).toString(16);
});
let unicode = result.replace(reSemicolon,
''
);
com.commContent = String(unicode);
console.log(com.commContent);
});
string.fromcharcode就好
第一次用 fromCharCode,问题解决了,非常感谢!