Esempio n. 1
0
        /// <summary>
        /// Calculates the number of bytes that must be present in the user data portion of the PDU.
        /// </summary>
        /// <param name="dataLength">The user data length specified in the PDU.</param>
        /// <param name="dataCodingScheme">The data coding scheme specified in the PDU.</param>
        /// <returns>The number of bytes (octets) that must be present, or, if decoding the user data, the number
        /// of remaining bytes that must be read.</returns>
        /// <remarks>The <b>dataLength</b> and <b>dataCodingScheme</b> parameters are used to
        /// calculate the number of bytes that must be present in the user data.</remarks>
        internal static int GetRemainingUserDataBytes(byte dataLength, byte dataCodingScheme)
        {
            int num;
            DataCodingScheme dataCodingScheme1 = DataCodingScheme.Decode(dataCodingScheme);
            byte             alphabet          = dataCodingScheme1.Alphabet;

            switch (alphabet)
            {
            case 0:
            {
                num = (int)Math.Ceiling((double)dataLength * 7 / 8);
                break;
            }

            case 1:
            case 2:
            {
                num = dataLength;
                break;
            }

            default:
            {
                num = (int)Math.Ceiling((double)dataLength * 7 / 8);
                break;
            }
            }
            return(num);
        }
Esempio 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 = PduParts.Decode7BitText(userData);
                break;
            }

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

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

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