Question

I am trying to check balance by sending

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

But it returns

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

How to convert it in normal text?

Was it helpful?

Solution

As Dan-o said:

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;
  }

Then Encoding.Unicode.GetString(ToByteArray(myString));

If that comes out jumbled, try Encoding.BigEndianUnicode.GetString(...) instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top