有没有办法判断一个 unicode 字符是控制字符、字母字符、数字字符还是符号字符?

发布于 2024-08-16 13:02:07 字数 53 浏览 7 评论 0原文

假设您拥有的只是二进制数据并且没有预先固定的函数,是否有一种模式或算法来对字符类型进行分类?

Assuming all you have is the binary data and no pre-canned functions, is there a pattern or algorithm to categorize the type of character?

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

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

发布评论

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

评论(3

世俗缘 2024-08-23 13:02:07

你要求 API 来告诉你。在Java 中,您使用Character 类。在C++中,可以使用ICU。如果您的语言没有此功能,您可以从 unicode.org 下载属性数据库并将其合并。

换句话说,没有模式或算法。 Unicode 联盟发布的表格包含了这些信息。

You ask an API to tell you. In Java, you use the Character class. In C++, you can use ICU. If your language doesn't have this, you download the properties database from unicode.org and incorporate it.

In other words, there is no pattern or algorithm. There are tables published by the Unicode consortium that contain the information.

香橙ぽ 2024-08-23 13:02:07

不,没有模式。您将需要创建一些查找表。 (嗯,我想你可以用迷宫般的 if 来完成它,但这不会很好。)

幸运的是,在大多数环境中,都有一个预装的 API 函数为您做这件事,因为构建字符类数据表非常无聊。

No, there's no pattern. You will need to create some look-up-tables. (Well, I suppose you could do it with a maze of if​s but it wouldn't be nice.)

Luckily in most environments there is a pre-canned API function to do it for you, because building the character class data tables is super-boring.

禾厶谷欠 2024-08-23 13:02:07

我最近发布了我的 FOSS Unicode 转换器,并且我在这个 (XML) 数据库中使用最新的 Unicode 字符数据库(附件 #44 - 包含 Unicode 5.2),

您可以搜索您请求的字符(十六进制代码)并查看它是否是数字或任何你想要的。

您可以测试这个 atmy 项目,如果它有用,您可以使用其数据库

http://unicode.codeplex.com 是该项目的主存储库。您可以在那里查看代码或获取可执行文件

I have recently publishmy FOSS Unicode Converter and I'm using from Latest Unicode Character Database (Annex #44 - that contain Unicode 5.2)

in this (XML) database youcan search for your requested Character (Hex Code) and see if it is numeric or whatever you want.

you can test this atmy project and if it was usefull you can use its database

http://unicode.codeplex.com is the main repository for the project. you can just see the code or get the executable there

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