Пример #1
0
 /// <summary>
 /// Swaps the semi-octets of a BCD encoded string.
 /// </summary>
 /// <param name="data">The string to convert.</param>
 /// <param name="totalWidth">The width to pad the string to before converting.
 /// Padding character is hexadecimal "F".</param>
 /// <remarks>
 /// <para>This method does not verify the actual contents of the string.</para>
 /// </remarks>
 /// <returns>The converted value.</returns>
 /// <exception cref="T:System.ArgumentException">totalWidth is not even.</exception>
 public static string EncodeSemiOctets(string data, int totalWidth)
 {
     if (totalWidth % 2 == 0)
     {
         return(BcdWorker.EncodeSemiOctets(data.PadRight(totalWidth, 'F')));
     }
     else
     {
         throw new ArgumentException("totalWidth must be even.", "totalWidth");
     }
 }
Пример #2
0
 private string EncodeSmscAddress(string address, byte addressType)
 {
     if (address.Length != 0)
     {
         string str    = BcdWorker.EncodeSemiOctets(address);
         byte   length = (byte)(str.Length / 2 + 1);
         return(string.Concat(Calc.IntToHex(length), Calc.IntToHex(addressType), str));
     }
     else
     {
         return(Calc.IntToHex(0));
     }
 }
Пример #3
0
 private string EncodeDestinationAddress(string address, byte addressType)
 {
     if (address.Length != 0)
     {
         byte   length = (byte)address.Length;
         string str    = BcdWorker.EncodeSemiOctets(address);
         return(string.Concat(Calc.IntToHex(length), Calc.IntToHex(addressType), str));
     }
     else
     {
         return(string.Concat(Calc.IntToHex(0), Calc.IntToHex(addressType)));
     }
 }
Пример #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);
 }