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/

(230) Comments

Blog Message http://bgtopsport.com/user/arerapexign118/

That is the very first time I frequented your web page and so far?


Blog Message http://89131.online/blog/view/79344/excellent-benefits-of-wholesale-fashion-clothing

Thanks for the article.Really looking forward to read more. Awesome.


Blog Message https://acid-lounge.org.uk/redir.php?url=https://nirvana.virtus.ufcg.edu.br%2Fwiki%2Fisensor%2Findex.php%2FUsu%C3%A1rio%3ACharmainelofft

Im grateful for the blog article.Much thanks again. Will read on


Blog Message http://www.creatorofchange.com/user-profile/tabid/90/userId/2052553/Default.aspx

Im grateful for the blog post. Really Great.


Blog Message https://www.masteromok.com/members/yearknee70/activity/609911/

I really liked your blog.Much thanks again.


Blog Message http://xn--h1aajgf.xn--p1ai/bitrix/redirect.php?event1=&event2=&event3=&goto=http://ibb.co/JKRJGcB

Thanks-a-mundo for the article.Really looking forward to read more. Awesome.


Blog Message https://en.indeeyah.org/wiki/index.php?title=User:ChuSnoddy40783

There is visibly a bunch to realize about this. I feel you made various nice points in features also.


Blog Message https://myspace.com/sautapeltimill

Very good comments, i really love this site , i am happy to bookmarked and tell it to my friend, thanks for your sharing.


Blog Message https://status.online

This is a topic that is near to my heart Best wishes!


Blog Message http://www.ruth-moschner-fanclub.de/link.php?url=http://lunashare.com/story/53029/

Promotional merchandise suppliers The most visible example of that is when the individual is gifted with physical attractiveness


Blog Message https://www.w88world.com/default.aspx?affiliateid=49567&language=id-id

Right now it appears like Drupal is the best blogging platform available right now. (from what I ave read) Is that what you are using on your blog?


Blog Message https://www.hamptonbaylightingcatalogue.net

Im grateful for the blog.Much thanks again. Really Great.


Blog Message http://bubblepalm8.thesupersuper.com/post/advantages-of-using-a-digital-marketing-agency

Thanks for sharing, this is a fantastic blog.Thanks Again. Really Cool.


Blog Message http://www.flowerbud.info/__media__/js/netsoltrademark.php?d=wavashop.online%2FShop%2Fbuy-fortnite-account%2F

This is very interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your magnificent post. Also, I ave shared your web site in my social networks!


Blog Message http://www.levulan.com.mx/__media__/js/netsoltrademark.php?d=www.pegaslighting.com%2Fyelforum%2Fhome.php%3Fmod%3Dspace%26uid%3D551080

Nice Site , guys! Good Articles aswell. Bookmarked

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