js怎么随机生成汉字呢?
 发布于 7 年前  作者 lovegnep  10471 次预览  最后一次回复是 7 年前  来自 问答 

如下这种生成随机汉字的方式打印不出汉字。有没有其它办法?

let word = '\\u' +(Math.round(Math.random() * 20901) + 19968).toString(16);
console.log(word);
//打印
\u64d3
4 回复
dislido
String.fromCodePoint(Math.round(Math.random() * 20901) + 19968)
liaoyinglong
function decodeUnicode(str) {
   str = str.replace(/\\/g, "%");
   return unescape(str);
}

Unicode解码一下?

JZLeung

image.png 但是会有很多奇怪的字。