我试图通过发送
来检查余额at+cusd=1,"*778#",15
但它返回
+CUSD: 0,"00420061006C0061006E00630065003A002000390034002E0039003200200054004B00
2E002000560061006C00690064006900740079003A002000300034002D004D00610079002D003100
34002E00200042006F006E00750073003A00200030002E003000300054004B002E00200046007200
6500650020004D0069006E003A00200030002E0046005200450045002000540075006E0065007300
210020004400690061006C002A003100320031002A00320031003100380033002300530065006900
2000540075006D0069002000620079004C00520042002E00440069006E006E006500720077006900
7400680020004D0069006D0020006400690061006C002A003800370037002A003100320031003900
310023",72
如何在普通文本中转换它?
答案 0 :(得分:4)
正如Dan-o所说:
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(...)
。