日期:2014-05-17 浏览次数:20923 次
internal protected sbyte[] Filter(string sValue) { sbyte []sArray = new sbyte[300]; try { Char [] cArray = sValue.ToCharArray(); for(int k = 0; k < cArray.Length; k++) { sArray[k] = Convert.ToSByte(cArray[k]); } return sArray; } catch(Exception e) { //MessageBox.Show(e.Message, "Error", // MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return null; } }
internal protected byte[] Filter( string sValue ) { //如果Utf8不行就换成Unicode,记不清到底用哪种编码了 byte[] sArray = System.Text.Encoding.UTF8.GetBytes( sValue ); return sArray; }
internal protected sbyte[] Filter(string sValue) { byte[] sArray = System.Text.Encoding.Unicode.GetBytes(sValue); //将byte[]类型转换为sbyte[]类型 sbyte[] mySByte = new sbyte[sArray.Length]; for (int i = 0; i < sArray.Length; i++) { if (sArray[i] > 127) mySByte[i] = (sbyte)(sArray[i] - 256); else mySByte[i] = (sbyte)sArray[i]; } return mySByte; }