有没有办法检查 unicode 文本是否使用某种语言? [英] Is there a way to check whether unicode text is in a certain language?

查看:30
本文介绍了有没有办法检查 unicode 文本是否使用某种语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将从用户那里获取需要验证是汉字的文本.

I'll be getting text from a user that I need to validate is a Chinese character.

有什么办法可以检查这个吗?

Is there any way I can check this?

推荐答案

根据这里在unicode网站上提供的信息 你可以找到中文或任何其他语言的块,然后实现一个解析器来检查一个单词是否在范围内.就像

According to the information provided here in unicode website you can find the block of Chinese or any other language and then implement a parser to check if a word is in the range or no. just like

public bool IsChinese(string text)
{
    return text.Any(c => c >= 0x20000 && c <= 0xFA2D);
}

注意

作为方便的参考,Unicode Consortium 此处提供了 Unicode 的搜索界面Hàn (汉) 数据库(Unihan).

As a handy reference, the Unicode Consortium here provides a search interface to the Unicode Hàn (漢) Database (Unihan).

我上面提供的数据库链接向您展示了字符

The database link I'd provided above is showing you the characters

这篇关于有没有办法检查 unicode 文本是否使用某种语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆