如下这种生成随机汉字的方式打印不出汉字。有没有其它办法?
let word = '\\u' +(Math.round(Math.random() * 20901) + 19968).toString(16);
console.log(word);
//打印
\u64d3
回复 (4)
J
但是会有很多奇怪的字。
D
String.fromCodePoint(Math.round(Math.random() * 20901) + 19968)
L
function decodeUnicode(str) {
str = str.replace(/\\/g, "%");
return unescape(str);
}
Unicode解码一下?
L
引用 dislido
@dislido OK
参与回复
登录后即可参与回复。登录