Monday, July 18, 2011

Detemine if a string contains characters beside english(for example chinese, japanese etc...)

Use the Unicode of a char to determine the Unicode Code Chart. you can find more information about the valid code charts here: http://www.unicode.org/charts/

I found a great piece of code to check if the given string contains chinese characters .

private bool  IsLetterChinese(string strText)
{
     int start = Convert.ToInt32("4E00",16);
     int end = Convert.ToInt32("9FBF",16);

     for(int i=0;i
     if ((Char.ConvertToUtf32(text, i) >= start) && (Char.ConvertToUtf32(text, i) <= end))

    return true;
    return false;
}

Thanks Marc,  for providing this awesome piece of code.

No comments:

Post a Comment

Health Benefits of Cashews

  Benefits of Cashews. Healthy food is an integral part of healthy body. Regular exercises such as Yoga and healthy diet is important to...