Beispiel #1
0
        private static byte[] EncodeString(DataCoding dataCoding, string str)
        {
            byte[] bytes;
            switch (dataCoding)
            {
            case DataCoding.Ascii:
                bytes = Encoding.ASCII.GetBytes(str);
                break;

            case DataCoding.Latin1:
                bytes = Latin1Encoding.GetBytes(str);
                break;

            case DataCoding.Ucs2:
                bytes = Encoding.BigEndianUnicode.GetBytes(str);
                break;

            case DataCoding.SmscDefault:
                bytes = SmscDefaultEncoding.GetBytes(str);
                break;

            default:
                throw new SmppException(SmppErrorCode.EsmeRunknownerr, "Unsupported encoding");
            }
            return(bytes);
        }
Beispiel #2
0
        private static string DecodeString(byte[] data, DataCoding dataCoding)
        {
            string result;

            switch (dataCoding)
            {
            case DataCoding.Ascii:
                result = Encoding.ASCII.GetString(data);
                break;

            case DataCoding.Latin1:
                result = Latin1Encoding.GetString(data);
                break;

            case DataCoding.Ucs2:
                result = Encoding.BigEndianUnicode.GetString(data);
                break;

            case DataCoding.SmscDefault:
                result = SmscDefaultEncoding.GetString(data);
                break;

            default:
                throw new SmppException(SmppErrorCode.EsmeRunknownerr, "Unsupported encoding");
            }
            return(result);
        }