title: GSM 7-bit encoding with 1 bit padding
body: <p>The octets from "Hello world" are: <code>E8 32 9B FD 06 DD DF 72 36 19</code></p>
  
  <p>And if apply padding it will become : <code>D0 65 36 FB 0D BA BF E5 6C 32</code></p>
  
  <p>(copy from wiki)</p>
  
  <p>Can I know what's the formula to encoding with 1-bit padding?</p>
  
  <p>Here is the formula of convert string to PDU that I edited :(thanks to source provider)
  *The whole complete formula is kinda long so I just post a part of it here...</p>
  
  <pre><code>    maxkeys = 160;
  
      function binToInt(x)//sp
     {
  var total = 0;  
  var power = parseInt(x.length)-0;   
  
  for(var i=0;i&lt;x.length;i++)
  {
      if(x.charAt(i) == '1')
      {
       total = total +Math.pow(2,power);
      }
      power --;
  }
  return total;
    }
  
    function intToHex(i) //sp
      {
       var sHex = "0123456789ABCDEF"; 
       h = ""; 
       i = parseInt(i);   
      for(j = 0; j &lt;= 3; j++)
       {
        h += sHex.charAt((i &gt;&gt; (j * 8 + 4)) &amp; 0x0F) +
          sHex.charAt((i &gt;&gt; (j * 8)) &amp; 0x0F);
        }
      return h.substring(0,2);
     }
  
  
   function stringToPDU(inpString,size) 
       {
  
  var bitSize = size[0].value * size[0].checked | size[1].value * size[1].checked | size[2].value * size[2].checked;
  
  var octetFirst = "";
  var octetSecond = ""; 
  var output = "";
  
  var DATA_ENCODING = "00"; 
  
  var VALID_PERIOD = "AA";
  
  var userDataSize;
  if (bitSize == 7)
  {
  
      userDataSize = intToHex(inpString.length);
  
      for(var i=0;i&lt;=inpString.length;i++)
      {
          if(i==inpString.length)
          {
              if (octetSecond != "") // AJA Fix overshoot
              {
                  output = output + "" + (intToHex(binToInt(octetSecond)));
              }
              break;
          }
          var current = intToBin(getSevenBit(inpString.charAt(i)),7);
  
          var currentOctet;
          if(i!=0 &amp;&amp; i%8!=0)
          {
              octetFirst = current.substring(7-(i)%8);
              currentOctet = octetFirst + octetSecond;    
  
              output = output + "" + (intToHex(binToInt(currentOctet)));
              octetSecond = current.substring(0,7-(i)%8); 
          }
          else
          {
              octetSecond = current.substring(0,7-(i)%8);
          }   
      }
  }
  
  //var data =  DATA_ENCODING + VALID_PERIOD + userDataSize;
  
  var PDU =   output;
  
  return  PDU;
        }
  
      &lt;input onclick="pduOut.value= stringToPDU(document.stringToPduForm.smsText.value.substring (0, maxkeys),document.stringToPduForm.size);" type="button" size="11" value="  Convert  " name="stringButton"&gt;
  </code></pre>
  
  <p>I need to know what changes needed so that the formula can encode message with 1-bit padding..but I not really understand the concept,can someone teach me?
  Thanks.</p>