My project requires use of user selectable languages. I will be reading string files from the SD card formatted in key value pairs. The Read uses a byte array to store the results of the read. The resulting byte array will be converted to a string, that will then be parsed into a string array. I have experimented with extended ascii:
byte[] buf = new byte[] { 0x41, 0xe9, 0x42,0x43,0x44, 0x0d, 0x0a }; // one extended ascii character
string s = Encoding.UTF8.GetString(buf);
int Iii = s.IndexOf("A"); // Iii = -1 <----!!!!!!!!!!!!!
Iii = s.IndexOf("\r\n"); // Iii = -1 <-----!!!!!!!!!!!!!!!
Iii = s.Length; // Iii = -1 <---------!!!!!!!!!
// convert the byte array by concatenating the characters:
string Sss = "";
for (int KK = 0; KK < buf.Length; ++KK)
{
Sss += (char)buf[KK];
}
Iii = Sss.IndexOf("A"); // Iii = 0
Iii = Sss.IndexOf("\r\n"); // Iii = 5
Iii = Sss.IndexOf("é"); // Iii = 1
note I have a byte array containing an extended ascii character. When I convert to string by Encoding.UTF8.GetString the resulting string does not allow the usual string methods: (indexof, length).
If I use brute force to create the string, then the indexof and length work OK, including finding the extended ascii character.
Shouldn’t IndexOf and Length (and other string methods) function on a UTF8 encoded string ?
Another issue is converting a font, arial, to include extended ascii (or Unicode). Does FontConverter allow this ?