News
  • Favorite
  • Facebook
  • Twitter
  • LinkedIn

Microsoft Press Pearson Education (InformIT)
Skip Navigation Links
Pearson Education (InformIT)
How to: Check that a string contains Arabic Characters using C#

Sometimes your application may need to know if a string contains Arabic characters for example if you create an application that sends SMS messages, you need to know the language of the message to handle payment and the length of SMS message differ from Arabic and English messages. You can do that by using the following utility helper method:
 

internal static bool ContainsArabicLetters(string text)

{

    foreach (char character in text.ToCharArray())

    {

        if (character >= 0x600 && character <= 0x6ff)

            return true;

 

        if (character >= 0x750 && character <= 0x77f)

            return true;

 

        if (character >= 0xfb50 && character <= 0xfc3f)

            return true;

 

        if (character >= 0xfe70 && character <= 0xfefc)

            return true;

    }

 

    return false;

} 

There is a way to check that a string contains Arabic characters with regular expressions as in the following method:

internal bool HasArabicCharacters(string text)

{

    Regex regex = new Regex(

        "[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]");

    return regex.IsMatch(text);

} 

This method simply checks that every character in the input text falls in the Unicode Character Code of Arabic characters. You can find all Arabic Unicode Character Codes in the following link http://www.unicode.org/charts/

(103) Comments

Blog Message http://gomovies123.org

Nicely? to be Remarkable post and will look forward to your future update. Be sure to keep writing more great articles like this one.


Blog Message http://www.seoinvancouver.com/

Incredible points. Outstanding arguments. Keep up the amazing effort.


Blog Message http://www.seoinvancouver.com/

Looking forward to reading more. Great blog post.Really looking forward to read more. Will read on


Blog Message https://www.amazon.com/RainbowTech-Waterproof-Automatic-Open-Fiberglass-Guaranteed/dp/B071LBGX1R

Appreciate you sharing, great blog.Really thank you! Will read on...


Blog Message http://cryptomunten.net

Wow, this piece of writing is fastidious, my younger sister is analyzing these things, therefore I am going to tell her.


Blog Message http://www.seoinvancouver.com/

Pas si sAаЂа›r si ce qui est dit sera mis en application.


Blog Message https://www.shamieye.com/

Its hard to find good help I am regularly proclaiming that its hard to procure good help, but here is


Blog Message http://www.codexploitcybersecurity.com/2017/11/windows-server-2012-r2-computer-account.html

Enjoyed every bit of your article. Want more.


Blog Message http://guvenilir-canli-bahis-oyna.com/

Really informative blog article.Thanks Again. Great.


Blog Message http://ow.ly/rG4k30ip0T6

Thanks for sharing, this is a fantastic blog.Much thanks again. Will read on


Blog Message https://www.poeticas.com.ar

Appreciate you sharing, great post.Much thanks again. Will read on...


Blog Message https://www.amazon.com/dp/B0785DLH5J

Thanks for sharing, this is a fantastic post.Thanks Again. Want more.


Blog Message https://www.techinfoworld.com/gbwhatsapp/

I was suggested this blog by my cousin. I am not sure whether this post is


Blog Message https://armorgames.com/user/ottosenmortensen7

you are really a good webmaster. The site loading speed is amazing. It seems that you are doing any unique trick. Also, The contents are masterwork. you have done a excellent job on this topic!


Blog Message https://spencerknowfitness.wordpress.com/

There is evidently a lot to identify about this. I consider you made various nice points in features also.

First Previous 1 2 3 4 5 6 7 Next Last 
Rating
Name
Email
Comment