AT命令USSD回复HEX

时间:2017-06-12 09:53:23

标签: at-command

AT命令USSD回复

AT+CUSD=1,"*2#",15

+CUSD: 0,"004D00530049005300440038003300360033",72

但是我需要这个回复用纯文本和#34;你的余额是27"

我的调制解调器是ZTE 190

2 个答案:

答案 0 :(得分:0)

您的USSD回复相当于" MSISD8363"

您可以使用此C#方法进行转换:

    public static byte[] StringToByteArray(string hex)
    {
        return Enumerable.Range(0, hex.Length)
            .Where(x => x % 2 == 0)
            .Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
            .ToArray();
    }

    private void ExecuteHex2Unicode()
    {
        var k = StringToByteArray(MessageBody);
        MessageBox.Show(Encoding.BigEndianUnicode.GetString(k));
    }

答案 1 :(得分:0)

仅拆分双引号区域

numpy.savetxt

//您的分割区域

       Like: string hexString = "0059006F007500720020006100630063006F0075006E0074002000620061006C0061006E00630065002000690073002000420044005400200030002E00300030002000560061006C00690064002000740069006C006C002000300032002D00300038002D0032003000320030003B";

像这样的StringToByteArray方法:

        byte[] bytes = StringToByteArray(hexString);
        var strArray = (Encoding.Default.GetString(
             bytes,
             0,
             bytes.Length - 1)).Split(new string[] { "\r\n", "\r", "\n", "\0" },
                                         StringSplitOptions.None);
        string str = string.Join("", strArray);