Add special 7-bit encoding and decoding functions for USSD coding

Handling 7-bit coding is a little different for USSD, as TS 03.38 states:

To avoid the situation where the receiving entity confuses 7 binary zero pad
bits as the @ character, the carriage return or <CR> character shall be used
for padding in this situation [...].

If <CR> is intended to be the last character and the message (including
the wanted <CR>) ends on an octet boundary, then another <CR> must be
added together with a padding bit 0. The receiving entity will perform
the carriage return function twice, but this will not result in misoperation
as the definition of <CR> [...] is identical to the definition of <CR><CR>.

The receiving entity shall remove the final <CR> character where the
message ends on an octet boundary with <CR> as the last character.
6 files changed