예제 #1
0
        public static string GetSafeText(string data, out bool lengthCorrected, out bool charsCorrected)
        {
            string str;
            string str2;

            lengthCorrected = false;
            charsCorrected  = false;
            if (data.Length > 160)
            {
                str             = data.Substring(0, 160);
                lengthCorrected = true;
            }
            else
            {
                str = data;
            }
            do
            {
                bool flag;
                str2 = TextDataConverter.StringTo7Bit(str, false, out flag);
                if (flag)
                {
                    charsCorrected = true;
                }
                if (str2.Length > 160)
                {
                    str             = data.Substring(0, str.Length - 1);
                    lengthCorrected = true;
                }
            }while (str2.Length > 160);
            return(TextDataConverter.SevenBitToString(str2));
        }
예제 #2
0
        protected string Decode7BitText()
        {
            string s      = TextDataConverter.OctetsToSeptetsStr(this.userData);
            int    length = s.Length;

            return(TextDataConverter.SevenBitToString(s, true));
        }
예제 #3
0
        protected void Encode7BitText(string text)
        {
            string data   = TextDataConverter.StringTo7Bit(text);
            int    length = data.Length;

            if (length > 160)
            {
                string[] strArray = new string[] { "Text is too long. A maximum of ", 160.ToString(), " resulting septets is allowed. The current input results in ", length.ToString(), " septets." };
                throw new ArgumentException(string.Concat(strArray));
            }
            this.SetUserData(TextDataConverter.SeptetsToOctetsInt(data), (byte)length);
        }
예제 #4
0
 protected string CreateAddressOfType(string address, byte type)
 {
     if (address != string.Empty)
     {
         if ((type == 0x91) && !address.StartsWith("+"))
         {
             return("+" + address);
         }
         AddressType type2 = new AddressType(type);
         if (type2.Ton == 5)
         {
             string s = BcdWorker.EncodeSemiOctets(address);
             return(TextDataConverter.SevenBitToString(TextDataConverter.OctetsToSeptetsStr(BcdWorker.GetBytes(s, 0, BcdWorker.CountBytes(s))), false));
         }
     }
     return(address);
 }
예제 #5
0
        /// <summary>
        /// Decodes the text from 7-Bit user data.
        /// </summary>
        /// <param name="userData">The user data to decode. Must contain an encoded GSM 7-Bit default text packed into octets.</param>
        /// <returns>The decoded user data.</returns>
        public static string Decode7BitText(byte[] userData)
        {
            string septetsStr = TextDataConverter.OctetsToSeptetsStr(userData);

            return(TextDataConverter.SevenBitToString(septetsStr, true));
        }
예제 #6
0
 public static int GetTextLength(string text)
 {
     return(TextDataConverter.StringTo7Bit(text).Length);
 }