ASCIIEncoding In Windows Phone 7

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;
    }

Leave a Comment