【问题标题】:How can I convert Unicode names to a Normal string?如何将 Unicode 名称转换为普通字符串?
【发布时间】: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


    【解决方案1】:

    经过数小时的反复试验,我找到了解决方案。

    公会名称 = ???? ????

    guild.name.normalize('NFKC') = 巴卡帮

    这让我可以用 Canvas 绘制名称 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-18
      • 2018-06-08
      • 1970-01-01
      • 2014-12-07
      • 1970-01-01
      • 2014-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多