使用 Javascript 查找 Unicode 字符名称

发布于 2024-09-25 10:39:04 字数 65 浏览 1 评论 0原文

当用户输入数字时,我需要找出 Unicode 字符的名称。例如,输入 0041 并得到“拉丁大写字母 A”作为结果。

I need to find out the names for Unicode characters when the user enters the number for it. An example would be to enter 0041 and get given "Latin Capital Letter A" as the result.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟花肆意 2024-10-02 10:39:04

据我所知,没有标准方法可以做到这一点。您可能可以解析 UnicodeData.txt 文件来获取此信息。

As far as I know, there isn't a standard way to do this. You could probably parse the UnicodeData.txt file to get this information.

终陌 2024-10-02 10:39:04

这应该就是您要找的东西。第一个数组只是 http://unicode.org/Public/UNIDATA/Index.txt| 替换换行符;

// this mess..
var unc = "A WITH ACUTE, LATIN CAPITAL LETTER   00C1| /*... really big array ...*/ |zwsp    200B";
var uncs=unc.split("|");
var final_a = [];
var final_s = "";
for each (var item in uncs) {
    var _T=item.split("\t");
    //final_a [_T[1]] = _T[0];
    final_s += '"' + _T[1] + '"' + ' : ' + '"' + _T[0] + '",';
}

console.log (final_s);

// yields..

var unicode_lookup = { /*really big array*/ }

// which we can use like so ...

alert(unicode_lookup["1D01"]);
// AE, LATIN LETTER SMALL CAPITAL

SO 不保留选项卡,因此如果您只是复制粘贴,第一部分可能无法工作。您会注意到某些字符是重复的,因此您可能需要进行一些清理。

Here should be what you're looking for. The first array is simply http://unicode.org/Public/UNIDATA/Index.txt with replacing newlines with |;

// this mess..
var unc = "A WITH ACUTE, LATIN CAPITAL LETTER   00C1| /*... really big array ...*/ |zwsp    200B";
var uncs=unc.split("|");
var final_a = [];
var final_s = "";
for each (var item in uncs) {
    var _T=item.split("\t");
    //final_a [_T[1]] = _T[0];
    final_s += '"' + _T[1] + '"' + ' : ' + '"' + _T[0] + '",';
}

console.log (final_s);

// yields..

var unicode_lookup = { /*really big array*/ }

// which we can use like so ...

alert(unicode_lookup["1D01"]);
// AE, LATIN LETTER SMALL CAPITAL

SO doesn't preserve tabs so the first part may not work if you simply copy-paste it. You'll note that some characters are duplicates so you may want to do some cleanup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文