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?
You can use regular expression to match with Supported Named Blocks:
private static readonly Regex cjkCharRegex = new Regex(@"\p{IsCJKUnifiedIdeographs}"); public static bool IsChinese(this char c) { return cjkCharRegex.IsMatch(c.ToString()); }
Then, you can use:
if (sometext.Any(z=>z.IsChinese())) DoSomething();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With