Exemplo n.º 1
0
        /// <summary>
        /// Decodes an address out of a PDU string.
        /// </summary>
        /// <param name="pdu">The PDU string to use.</param>
        /// <param name="index">The index where to start in the string.</param>
        /// <param name="address">The address (phone number) read.</param>
        /// <param name="addressType">The address type of the read address.</param>
        public static void DecodeGeneralAddress(string pdu, ref int index, out string address, out byte addressType)
        {
            int num;
            int num1 = index;
            int num2 = num1;

            index = num1 + 1;
            byte num3 = BcdWorker.GetByte(pdu, num2);
            int  num4 = index;
            int  num5 = num4;

            index       = num4 + 1;
            addressType = BcdWorker.GetByte(pdu, num5);
            if (num3 <= 0)
            {
                address = string.Empty;
                return;
            }
            else
            {
                bool flag = false;
                if (num3 % 2 != 0)
                {
                    num = num3 + 1;
                }
                else
                {
                    num = (int)num3;
                }
                int length = num / 2;
                if (index * 2 + length * 2 > pdu.Length - length * 2)
                {
                    length = (pdu.Length - index * 2) / 2;
                    flag   = true;
                }
                AddressType addressType1 = new AddressType(addressType);
                if (addressType1.Ton != 5)
                {
                    string bytesString = BcdWorker.GetBytesString(pdu, index, length);
                    index = index + length;
                    if (flag)
                    {
                        address = BcdWorker.DecodeSemiOctets(bytesString).Substring(0, length * 2);
                        return;
                    }
                    else
                    {
                        address = BcdWorker.DecodeSemiOctets(bytesString).Substring(0, num3);
                        return;
                    }
                }
                else
                {
                    byte[] bytes = BcdWorker.GetBytes(pdu, index, length);
                    index   = index + length;
                    address = PduPartsEx.Decode7BitText(bytes);
                    return;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Decodes text from user data in the specified data coding scheme.
        /// </summary>
        /// <param name="userData">The user data to decode. Must contain text according to the specified data coding scheme.</param>
        /// <param name="dataCodingScheme">The data coding scheme specified in the PDU.</param>
        /// <returns>The decoded user data.</returns>
        public static string DecodeText(byte[] userData, byte dataCodingScheme)
        {
            string str;
            byte   alphabet = DataCodingScheme.Decode(dataCodingScheme).Alphabet;
            byte   num      = alphabet;

            switch (num)
            {
            case 0:
            {
                str = PduPartsEx.Decode7BitText(userData);
                break;
            }

            case 1:
            {
                //Label0:
                str = PduPartsEx.Decode7BitText(userData);
                break;
            }

            case 2:
            {
                str = PduPartsEx.DecodeUcs2Text(userData);
                break;
            }

            default:
            {
                //goto Label0;
                str = PduPartsEx.Decode7BitText(userData);
                break;
            }
            }
            return(str);
        }