SMS dedicated coding format conversion (such as CMPP, SGIP)

xiaoxiao2021-03-06  35

PUBLIC ENUM CODING {ASCII = 0, binary = 4, ucs2 = 8, GBK = 15} public static string decode (Byte [] BUF, INT StartIndex, Int Length, Coding Coding {string str = string.empty; if (Coding == CODING.ASCII) {System.Text.ASCIIEncoding AsciiEncoder = new System.Text.ASCIIEncoding (); str = new String (AsciiEncoder.GetChars (buf, StartIndex, Length)); str = str.Split ( '/ 0' ) [0];

} else if (coding == code) {byte [] temp = new byte [length]; for (int i = 0; i

} Return str;} public static Byte [] Encode (String str, CODING coding) {Byte [] buf = null; if (coding == CODING.ASCII) {System.Text.ASCIIEncoding AsciiEncoder = new System.Text.ASCIIEncoding ( ); buf = AsciiEncoder.GetBytes (str);} else if (coding == CODING.UCS2) {System.Text.UnicodeEncoding UnicodeEncoder = new System.Text.UnicodeEncoding (); buf = UnicodeEncoder.GetBytes (str); Byte temp = 0; for (int i = 0; i

Return BUF;

}

转载请注明原文地址:https://www.9cbs.com/read-58295.html

New Post(0)