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