gsm7

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pack7Bit

func Pack7Bit(u []byte, fillBits int) []byte

Pack7Bit packs an array of septets into an 8bit array as per the packing rules defined in 3GPP TS 23.038 Section 6.1.2.1 The padBits is the number of bits of pad to place at the beginning of the packed array, as the packed septets may not start on an octet boundary. Packed arrays containing 8n or 8n-1 digits both return 8n septets. The caller must be aware of the number of expected digits in order to distinguish between a 0 septet ending the sequence in the 8n case, and 0 padding in the 8n-1 case.

func Pack7BitUSSD

func Pack7BitUSSD(u []byte, fillBits int) []byte

Pack7BitUSSD packs an array of septets into an 8bit array as per the packing rules defined in 3GPP TS 23.038 Section 6.1.2.3 The padBits is the number of bits of pad to place at the beginning of the packed array, as the packed septets may not start on an octet boundary. A filler CR is added to the final octet if there are 7 bits unused (to distinguish from the 0x00 septet), or if the last septet is CR and ends on an octet boundary (so it wont be considered filler).

func Unpack7Bit

func Unpack7Bit(p []byte, fillBits int) []byte

Unpack7Bit unpacks septets, packed into an 8bit array as per the packing rules defined in 3GPP TS 23.038 Section 6.1.2.1, into an array of septets. The fillBits is the number of bits of pad at the beginning of the src, as the packed septets may not start on an octet boundary.

func Unpack7BitUSSD

func Unpack7BitUSSD(p []byte, fillBits int) []byte

Unpack7BitUSSD unpacks septets, packed into an 8bit array, as per the packing rules defined in 3GPP TS 23.038 Section 6.1.2.3, into an array of septets. The fillBits is the number of bits of pad at the beginning of the src, as the packed septets may not start on an octet boundary. Any trailing CR is assumed to be filler if it ends an octet boundary, or if it starts on an octet boundary and the previous character is also CR.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder converts from GSM7 to UTF-8 using a particular character set.

func NewDecoder

func NewDecoder() Decoder

NewDecoder returns a new GSM7 decoder which uses the default character set.

func (*Decoder) Decode

func (d *Decoder) Decode(src []byte) ([]byte, error)

Decode converts the src from unpacked GSM7 to UTF-8.

func (Decoder) Strict

func (d Decoder) Strict() Decoder

Strict makes the Decoder return an error if an unknown character is detected when looking up a septet in the character set (not the extension set).

func (Decoder) WithCharset

func (d Decoder) WithCharset(set charset.Decoder) Decoder

WithCharset replaces the character set map used by the Decoder.

func (Decoder) WithExtCharset

func (d Decoder) WithExtCharset(ext charset.Decoder) Decoder

WithExtCharset replaces the extension character set map used by the Decoder.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder converts from UTF-8 to GSM7 using a particular character set.

func NewEncoder

func NewEncoder() Encoder

NewEncoder returns a new GSM7 encoder which uses the default character set.

func (*Encoder) Encode

func (e *Encoder) Encode(src []byte) ([]byte, error)

Encode converts the src from UTF-8 to GSM7 and writes the result to dst. The return value includes the encoded GSM7 bytes, and any error that occurred during encoding.

func (Encoder) WithCharset

func (e Encoder) WithCharset(set charset.Encoder) Encoder

WithCharset replaces the character set map used by the Encoder.

func (Encoder) WithExtCharset

func (e Encoder) WithExtCharset(ext charset.Encoder) Encoder

WithExtCharset replaces the extension character set map used by the Encoder.

type ErrInvalidSeptet

type ErrInvalidSeptet byte

ErrInvalidSeptet indicates a septet cannot be decoded.

func (ErrInvalidSeptet) Error

func (e ErrInvalidSeptet) Error() string

type ErrInvalidUTF8

type ErrInvalidUTF8 rune

ErrInvalidUTF8 indicates a rune cannot be converted to GSM7.

func (ErrInvalidUTF8) Error

func (e ErrInvalidUTF8) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL