0

C# 6.0

Huawei modems use PDU for USSD, I need a c# code or any library to Encode plain text to PDU and decode PDU to plain text ex: *222# ==> 2A994C3602 and vice versa. Thanks.

user1104916
  • 103
  • 1
  • 11

1 Answers1

0
       public static string GetPDUString(string plainString)
    {
        var bytes = Encoding.Default.GetBytes(plainString);
        var packedBytes = PduBitPacker.PackBytes(bytes);
        var hexString = PduBitPacker.ConvertBytesToHex(packedBytes);
        return hexString;
    }
    public static string GetPlainText(string pduString)
    {
        var packedBytes = PduBitPacker.ConvertHexToBytes(pduString);
        var unpackedBytes = PduBitPacker.UnpackBytes(packedBytes);
        return System.Text.Encoding.Default.GetString(unpackedBytes, 0, unpackedBytes.Length);
    }
user1104916
  • 103
  • 1
  • 11