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/

(212) Comments

Blog Message http://seatoskykiteboarding.com/

Your house is valueble for me. Thanks!aаАа’б‚Т€ТšаЂаŒаАТ’аЂа†


Blog Message http://seatoskykiteboarding.com/

I will right away seize your rss as I can at find your email subscription hyperlink or newsletter service. Do you ave any? Please let me realize in order that I could subscribe. Thanks.


Blog Message http://seatoskykiteboarding.com/

Thanks so much for the blog post.Really looking forward to read more. Really Great.


Blog Message http://thesoundofsleep.com/__media__/js/netsoltrademark.php?d=frazerlevy.blogspot.com

Thanks for this great article! It has been extremely useful. I wish that you will proceed posting your knowledge with me.


Blog Message http://markets.financialcontent.com/ttmtech/news/read/36689331

your web hosting is OK? Not that I am complaining, but slow loading instances


Blog Message http://orphans.org/__media__/js/netsoltrademark.php?d=angelhagan.blogspot.com/

Thanks for the blog post.Really looking forward to read more. Awesome.


Blog Message http://www.ccvq.ca/members/joieforde24226/profile/

I truly appreciate this article.Really looking forward to read more. Awesome.


Blog Message http://maritzagoldwarequi.tubablogs.com/it-is-not-recommended-to-use-buildings-to-force-your-opponent-to-spawn-further-away-as-and-are-approximate-conversions-to-u-s

Way cool! Some very valid points! I appreciate you writing this write-up and the rest of the website is really good.


Blog Message http://munoz3259ri.canada-blogs.com/the-proposal-was-rejected-but-the-company-separately-announced-a-small-increase-in-the-diversity-of-the-north-east-neighbourhood-around-the-school

You have mentioned very interesting points ! ps decent website. I am going to a special place when I die, but I want to make sure my life is special while I am here. by Payne Stewart.


Blog Message http://urbanbicyclegallery.net/__media__/js/netsoltrademark.php?d=kellystacey.blogspot.com

This is one awesome blog post.Thanks Again. Will read on


Blog Message http://tripgetaways.org/2018/07/26/weekend-starting-hours-for-shops-in-america/

Pretty nice post. I just stumbled upon your weblog and wished to say that I ave really enjoyed browsing your blog posts. In any case I all be subscribing to your feed and I hope you write again soon!


Blog Message http://pets-manuals.xyz/story.php?id=26767

Very nice info and straight to the point. I am not sure if this is really the best place to ask but do you guys have any ideea where to hire some professional writers? Thanks


Blog Message http://decision-analyst.org/__media__/js/netsoltrademark.php?d=tyreseguevara.blogspot.com

wonderful issues altogether, you just won a new reader. What could you suggest about your publish that you made some days ago? Any positive?


Blog Message http://iamag.org/blog/view/22896/the-best-way-to-recognize-every-thing-on-big-data-icos

Wow! Thank you! I continually wanted to write on my site something like that. Can I implement a portion of your post to my website?


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

Is there free software or online database to keep track of scheduled blog posts? I would also like it to keep a record of past and future posts. I am trying to avoid creating a spreadsheet in Excel..

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