Is there a Way to use ASCIIEncoding in Windows Phone 7?
Unless im doing Something Wrong Encoding.ASCII Doesn't Exist and I'm needing it for C# -> PHP Encryption (As PHP Only Uses ASCII in SHA1 Encryption).
Any Suggestions?
Thanks.
Is there a Way to use ASCIIEncoding in Windows Phone 7?
Unless im doing Something Wrong Encoding.ASCII Doesn't Exist and I'm needing it for C# -> PHP Encryption (As PHP Only Uses ASCII in SHA1 Encryption).
Any Suggestions?
Thanks.
According to this MS forum thread, Windows Phone 7 does not support Encoding.ASCII
.
Not really seeing any detail in your question this could be off track. You are right Silverlight has no support for the ASCII encoding.
However I suspect that in fact UTF8 will do what you need. Its worth bearing in mind that a sequence of single byte ASCII only characters and the same set of characters encoded as UTF-8 are identical. That is the the complete ASCII character set is repeated verbatim by the first 128 single byte code points in UTF-8.
It is easy to implement yourself, Unicode never messed with the ASCII codes:
public static byte[] StringToAscii(string s) {
byte[] retval = new byte[s.Length];
for (int ix = 0; ix < s.Length; ++ix) {
char ch = s[ix];
if (ch <= 0x7f) retval[ix] = (byte)ch;
else retval[ix] = (byte)'?';
}
return retval;
}