Search code examples
c#unicode.net-4.0

Is there a way to check whether unicode text is in a certain language?


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?


Solution

  • 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);
    }
    

    Note that

    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