public static byte[] StringToAscii(string s) { var retval = new byte[s.Length]; for (var ix = 0; ix < s.Length; ++ix) { var ch = s[ix]; if (ch <= 0x7f) retval[ix] = (byte)ch; else retval[ix] = (byte)'?'; } return retval; } }