Class GSM7BitAlphabet


  • public class GSM7BitAlphabet
    extends Object
    Utilities for translating between Strings and values in the GSM 7-bit alphabet, as defined in 3GPP TS 23.038 section 6.2.1.

    This class deals in terms of "unpacked" values, stored as one 7-bit value per byte. To transform this to the packed representations needed by SMS/CBS/USSD, use the methods in GSM7BitPacking.

    • Method Detail

      • decode

        public static String decode​(byte[] src,
                                    int srcpos,
                                    int count)
        Decode an unpacked representation in the 7-bit alphabet to a String
        Parameters:
        src - the array to read from
        srcpos - the offset (in bytes) in src to read
        count - the number of codes to read
        Returns:
        a decoded String
      • encode

        public static void encode​(String src,
                                  byte[] dst,
                                  int dstpos)
        Encode a String to an unpacked 7-bit representation
        Parameters:
        src - the string to encode
        dst - the array to encode to
        dstpos - the offset within dst to start at
      • countCharacters

        public static int countCharacters​(String src)
        Count the number of 7-bit characters needed to represent a given String (including escapes)
        Parameters:
        src - the string to examine
        Returns:
        number of 7-bit characters needed to represent src, or -1 if there are unsupported characters present