我正在尝试通过发送来检查余额

at+cusd=1,"*778#",15


但它返回

+CUSD: 0,"00420061006C0061006E00630065003A002000390034002E0039003200200054004B00
2E002000560061006C00690064006900740079003A002000300034002D004D00610079002D003100
34002E00200042006F006E00750073003A00200030002E003000300054004B002E00200046007200
6500650020004D0069006E003A00200030002E0046005200450045002000540075006E0065007300
210020004400690061006C002A003100320031002A00320031003100380033002300530065006900
2000540075006D0069002000620079004C00520042002E00440069006E006E006500720077006900
7400680020004D0069006D0020006400690061006C002A003800370037002A003100320031003900
310023",72


如何将其转换为普通文本?

最佳答案

正如Dano所说:

public static byte[] ToByteArray (this String HexString) {
    int NumberChars = HexString.Length;
    var bytes = new byte[NumberChars / 2];
    for (int i = 0; i < NumberChars; i += 2) {
      bytes[i / 2] = Convert.ToByte(HexString.Substring(i, 2), 16);
    }
    return bytes;
  }


然后Encoding.Unicode.GetString(ToByteArray(myString));

如果结果杂乱无章,请尝试使用Encoding.BigEndianUnicode.GetString(...)

关于c# - 用AT命令检查余额,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22279968/

10-14 07:31