Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I validate hebrew string input in C#?

Tags:

c#

I have a textbox and I want to validate that the user enters only hebrew strings. How can I do that?

like image 767
Micky Fridman Avatar asked Feb 26 '23 13:02

Micky Fridman


1 Answers

The obvious approach is to check the codepoints with TextBox.Text.ToCharArray(). Hebrew glyphs are codepoints 0x0580 through 0x05ff with supplementals 0xfb1d through 0xfb4f. Plus the arabic digits.

Not being a native speaker, I would however assume that Latin characters can appear when spelling trade mark names, foreign words and acronyms. Note the use of "RSS" in this page. Which put a pretty big hole in any attempt to verify the text.

like image 127
Hans Passant Avatar answered Mar 06 '23 17:03

Hans Passant