I have this code work in desktop app, but it doesn’t work in Windows 8 Store app, because System.Text does not have ASCIIEncoding support anymore:
tagdata is a byte array.
ASCIIEncoding.ASCII.GetString(tagdata).Trim();
Should I use UT8Encoding? I just want to convert the byte array into ASCII text.
Thank you.
For a start, I’d suggest using
Encoding.ASCIIeverywhere instead ofASCIIEncoding.ASCII– the latter somewhat implies that theASCIIproperty is a member of theASCIIEncodingclass, which it’s not.If you know that your byte array is just ASCII text, then you can use
Encoding.UTF8freely, as every character present in ASCII is represented the same way in both UTF-8 and ASCII.If you want to check the validity first, you just need to check that every byte in the array is less than 128