How can I determine whether a char in a string is an ASCII, ISO 8859-1 or Unicode-only character?
Created May 7, 2012
J Rajendran See Is ASCII considered a subset of Unicode, or are they disjoint sets? for the reason the code below works.
Assuming your target string is str1:
int len = str1.length();
int codePoint;
char[] chars = str1.toCharArray();
for( int i=0; i < len; i++ )
{
codePoint = (int) chars[i];
if (codePoint < 128)
{
// This is an ascii char.
}
else
if (codePoint < 256)
{
// This is an ISO 8859-1 char.
}
else
{
// This is a Unicode-only Char.
}
}