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/

(260) Comments

Blog Message http://thefinancialmetrics.com/news/cookie-s-kids-children-school-uniform-fashion-trends-for-2019/144388/

Very good article post.Much thanks again. Want more.


Blog Message https://en.gravatar.com/hake167

Very nice article. I certainly appreciate this website. Continue the good work. Thanks!


Blog Message http://eliteweb.bravesites.com/

Thank which you bunch with regard to sharing this kind of with all you genuinely admit a minute ago what you are speaking approximately! Bookmarked. Entertain also obtain guidance from my web page


Blog Message http://normand1401kj.journalwebdir.com/asset-classes-a-group-of-assets-significant-reduction-to-the-corporate-tax-rate-and-a-reduction-in-most-individual-tax-rates

It'а†s in point of fact a nice and helpful piece of info. I am glad that you shared this helpful info with us. Please stay us up to date like this. Thanks for sharing.


Blog Message http://xn--b1adccaenc8bealnk.com/users/lyncEnlix979

That is a good tip particularly to those fresh to the blogosphere. Brief but very accurate info Thanks for sharing this one. A must read post!


Blog Message http://up.result-nic.in/

Wow! This could be one particular of the most helpful blogs We have ever arrive across on this subject. Basically Fantastic. I am also a specialist in this topic so I can understand your hard work.


Blog Message http://countrymouse.com/__media__/js/netsoltrademark.php?d=guidemom.com%2Findex.php%3Fqa%3Duser%26qa_1%3Dcallroute19/

Your personal stuffs outstanding. At all times handle it up!


Blog Message http://melbourne-residence.jigsy.com/

Looking forward to reading more. Great article post. Really Cool.


Blog Message http://www.short4free.us/smallbusinessseoservices78438

This particular blog is definitely cool and factual. I have picked up many helpful stuff out of this amazing blog. I ad love to return again soon. Thanks a lot!


Blog Message http://b-architects.biz/__media__/js/netsoltrademark.php?d=www.spoke.com%2Flists%2F5c76cb781433673bc3019cf9

It as nice to come across a blog every once in a while that isn at the


Blog Message http://3dprintmoonlamp.site123.me/

Really informative blog.Really thank you! Awesome.


Blog Message http://turkeya.life/index.php?action=profile;area=forumprofile;u=355417

ThаА аЂа•re is noticeablаАааБТ“ a ton to realize about thаАаб‚Т€Т“аАаб‚Т€а‚.


Blog Message http://soccerfan.biz/index.php?qa=user&qa_1=menubelt8

in our community. Your site offered us with helpful information to


Blog Message http://oralsurgerymke.info/__media__/js/netsoltrademark.php?d=webflow.com%2Finstasinas

Nice post. I learn something totally new and challenging on sites I stumbleupon everyday. It as always useful to read articles from other authors and practice something from their websites.


Blog Message http://nakenedamerurw.tosaweb.com/all-futures-trade-is-1-50-per-side-per-contract-plus-exchange-fees-excluding-provider-swill-help-them-avoid-potential-losses-or-reimburse-them-in-case-of-a-covered-loss-related-to-political-causes

It as going to be end of mine day, except before ending I am reading this impressive piece of

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