title: GSM7 bit padding for SMS concatenation in C#
body: <p>I'm writing an algorithm for splitting large SMS messages(>140 bytes) into smaller parts(140 bytes) in order to be able to send them to mobile operators via SMPP protocol. </p>
  
  <p>Each part has an UDH(User Data Header) consisting of 6 or 7 bytes. The documentation I used for this is:</p>
  
  <p><a href="http://en.wikipedia.org/wiki/Concatenated_SMS" rel="nofollow">http://en.wikipedia.org/wiki/Concatenated_SMS</a></p>
  
  <p><a href="http://mobiletidings.com/2009/02/18/combining-sms-messages/" rel="nofollow">http://mobiletidings.com/2009/02/18/combining-sms-messages/</a></p>
  
  <p>So the structure of a message part will be:</p>
  
  <p>[UDH][PART_BODY] where</p>
  
  <p>[UDH] - 6 or 7 bytes</p>
  
  <p>[PART_BODY] - 133 or 134 bytes</p>
  
  <p>Also, each of the sources above mention that, if GSM7 encoding is used, padding bits should be added at the beginning of the part body to ensure that the part body will start on a septet boundary.</p>
  
  <p>This is where I start to get confused... While I understood how septets are stored in a byte and what padding  means, I don't understand how to implement this in my actual code that looks like this:</p>
  
  <pre><code>public void AddUDHToSmSend(ref SMSend Sm, byte[] Udh)
  {           
      byte[] msg = new byte[Udh.Length + Sm.Message.Length];
      Udh.CopyTo(msg, 0);
      Sm.Message.CopyTo(msg, Udh.Length);
      Sm.Message = msg;       
  }
  </code></pre>
  
  <p>Udh - an array of bytes</p>
  
  <p>Sm.Message - an array of bytes representing the part body</p>
  
  <p>How can I add a padding bit in this context?</p>
  
  <p>Thanks!</p>