How can I check Hebrew string input in C #?

I have a text box, and I want to verify that the user enters only Hebrew lines. How can i do this?

+4
source share
5 answers

The obvious approach is to check the code points using TextBox.Text.ToCharArray (). Hewbrew glyphs are code points from 0x0580 to 0x05ff with additions 0xfb1d to 0xfb4f. In addition, Arabic numerals.

Without being a native speaker, I would suggest that Latin characters may appear when spelling brand names, foreign words, and acronyms. Please note the use of "RSS" in this page . Which put a rather large hole in an attempt to check the text.

+5
source

One way to do this is to grab the ASP.NET AJAX Control Toolkit @ http://www.asp.net/ajax/ajaxcontroltoolkit/samples/

Use the FilteredTextBox element (basically a text field extension).

Keep in mind that this will only prevent the form from submitting if it contains non-Jewish lines. This does not stop them from entering them in the text box.

But I suppose this will create another problem. You will need to determine what other characters are allowed, punctuation, numbers, etc.

What problem are you trying to solve? Perhaps we can come up with something else.

+1
source

avoid unicode characters in code

private const char FirstHebChar = (char)1488; //א private const char LastHebChar = (char)1514; //Χͺ private static bool IsHebrew(this char c) { return c >= FirstHebChar && c <= LastHebChar; } 

see http://blogs.microsoft.co.il/shimmy/2012/02/03/determine-if-char-is-hebrew-2/

+1
source

Use a regular expression that ensures that the text is in a specific range. You probably want to add a space character, as well as any built-in R-to-L and LR characters.

0
source

If you do this using an ASP.NET web application, you can use the RegularExpressionValidator control with Unicode escape characters to create a RegEx Match for valid strings.

0
source

All Articles