【发布时间】:2021-09-21 11:47:16
【问题描述】:
Discord 允许用户和服务器基本上使用任何带有 unicode、表情符号等的名称。我不需要解决所有名称的解决方案,但我需要尽可能多地“规范化”unicode。我在这里尝试过解决方案,但由于某种原因,unicode 根本没有被转换。这就是我现在所拥有的。我需要类似'??????????????? ???????????????成为“巴卡帮”
function unicodeToChar(unicode) {
const arr = [];
for (const char of unicode) {
arr.push(char);
}
const newWord = [];
arr.forEach(letter => newWord.push(String.fromCharCode(parseInt(letter))));
return newWord.join('');
}
【问题讨论】:
标签: javascript arrays replace unicode discord