private static uint CountUtf8Bytes(char[] chars)
{
uint utfLength = 0;
int c = 0;
for(int i = 0; i < chars.Length; i++)
{
c = chars[i];
if((c >= 0x0001) && (c <= 0x007F))
{
utfLength++;
}
else if(c > 0x07FF)
{
utfLength += 3;
}
else
{
utfLength += 2;
}
}
return utfLength;
}