Package net.freeutils.charset
Class PackedGSMCharset
java.lang.Object
java.nio.charset.Charset
net.freeutils.charset.EscapedByteLookupCharset
net.freeutils.charset.GSMCharset
net.freeutils.charset.PackedGSMCharset
- All Implemented Interfaces:
Comparable<Charset>
- Direct Known Subclasses:
CCPackedGSMCharset
,SCPackedGSMCharset
The PackedGSMCharset class handles the encoding and decoding of the
GSM default encoding charset, with packing as per GSM 03.38 spec.
The encoding and decoding are based on the mapping at
http://www.unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT
- Since:
- 2007-03-20
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
The Decoder inner class handles the decoding of the Packed GSM default encoding charset.protected class
The Encoder inner class handles the encoding of the Packed GSM default encoding charset. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PackedGSMCharset
(String canonicalName, String[] aliases, int[] byteToChar, int[] byteToCharEscaped, int[][] charToByte, int[][] charToByteEscaped) Initializes a new charset with the given canonical name and alias set, and byte-to-char/char-to-byte lookup tables. -
Method Summary
Methods inherited from class net.freeutils.charset.EscapedByteLookupCharset
contains
Methods inherited from class java.nio.charset.Charset
aliases, availableCharsets, canEncode, compareTo, decode, defaultCharset, displayName, displayName, encode, encode, equals, forName, forName, hashCode, isRegistered, isSupported, name, toString
-
Constructor Details
-
PackedGSMCharset
protected PackedGSMCharset(String canonicalName, String[] aliases, int[] byteToChar, int[] byteToCharEscaped, int[][] charToByte, int[][] charToByteEscaped) Initializes a new charset with the given canonical name and alias set, and byte-to-char/char-to-byte lookup tables.- Parameters:
canonicalName
- The canonical name of this charsetaliases
- An array of this charset's aliases, or null if it has no aliasesbyteToChar
- a byte-to-char conversion table for this charsetbyteToCharEscaped
- a byte-to-char conversion table for this charset for the escaped characterscharToByte
- a char-to-byte conversion table for this charset. It can be generated on-the-fly by calling createInverseLookupTable(byteToChar).charToByteEscaped
- a char-to-byte conversion table for this charset for the escaped characters- Throws:
IllegalCharsetNameException
- If the canonical name or any of the aliases are illegal
-
-
Method Details
-
newDecoder
Constructs a new decoder for this charset.- Overrides:
newDecoder
in classEscapedByteLookupCharset
- Returns:
- A new decoder for this charset
-
newEncoder
Constructs a new encoder for this charset.- Overrides:
newEncoder
in classEscapedByteLookupCharset
- Returns:
- A new encoder for this charset
- Throws:
UnsupportedOperationException
- If this charset does not support encoding
-
unpack
public static byte[] unpack(byte[] in) Unpacks the given data into original bytes. This is an external utility method and is not used internally by the Charset implementation.- Parameters:
in
- the input bytes- Returns:
- the unpacked output bytes
-
pack
public static byte[] pack(byte[] in) Packs the given data into full bytes. This is an external utility method and is not used internally by the Charset implementation.- Parameters:
in
- the input bytes- Returns:
- the packed output bytes
-