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/

(152) Comments

Blog Message http://noticiasdecantabria.com/barcelona-de-noche/

This particular blog is obviously educating and also factual. I have found many helpful things out of this amazing blog. I ad love to go back every once in a while. Thanks a bunch!


Blog Message http://elclarinweb.com/curiosidades/conoce-los-mejores-strip-club-barcelona

I'а†ve recently started a site, the information you provide on this web site has helped me greatly. Thank you for all of your time & work.


Blog Message https://slashdot.org/~stripclubbarcelona

It as not that I want to replicate your web site, but I really like the design. Could you let me know which style are you using? Or was it custom made?


Blog Message https://www.graphicallyspeaking.ca/services/digital-marketing/search-engine-optimization

Really appreciate you sharing this blog.Thanks Again. Want more.


Blog Message http://pushme.one

Very good article. I certainly appreciate this site. Continue the good work!


Blog Message https://www.youtube.com/watch?v=eLcMx6m6gcQ

IaаАа’б‚Т€ТšаЂаŒаАа’б‚Т€ТžаБТžve been absent for some time, but now I remember why I used to love this weblog. Thank you, I will try and check back much more often. How regularly you update your internet web site?


Blog Message http://www.dispensary.international

Thank you ever so for you article.Thanks Again. Really Cool.


Blog Message http://blogsdelagente.com/decorahogar/2016/02/18/centros-de-mesa/

Terrific work! This is the type of information that should be shared around the web. Shame on Google for not positioning this post higher! Come on over and visit my web site. Thanks =)


Blog Message https://www.ccn.com/physical-bitcoin-banknotes-launched-in-singapore-to-drive-adoption-2/

The best and clear News and why it means a great deal.


Blog Message http://propertymaintenancevancouver.ca

I want gathering useful information, this post has got me even more info!


Blog Message http://www.pronoahtech.com.ng

If the tenant is unable to supply a reference whatsoever, a purple flag really should go up.


Blog Message https://templerungame.net

You, my friend, ROCK! I found exactly the information I already searched all over the place and simply could not find it. What an ideal site.


Blog Message http://onlinedispensaryquebec.com/

You ave offered intriguing and legitimate points which are thought-provoking in my viewpoint.


Blog Message http://bitcoinist.com/bitcoin-price-analysis-10k-are-we-there-yet/

There is obviously a bunch to identify about this. I consider you made certain good points in features also.


Blog Message https://www.linkedin.com/in/digitalbusinessdirector/

I reckon something really special in this website.

First Previous 1 2 3 4 5 6 7 8 9 10  ... Next Last 
Rating
Name
Email
Comment