Skip to main content

Module gsm7

Module gsm7 

Source
Expand description

GSM 7-bit default alphabet, extension table and national language tables (3GPP TS 23.038 §6.2.1 and Annex A), plus septet packing (§6.1.2.1).

Septets are handled unpacked (one u8 per septet, values 0..=0x7F) by encode/decode and bit-packed by pack/unpack.

National tables covered: Turkish (locking + single shift), Spanish (single shift; 23.038 defines no Spanish locking table), Portuguese (locking + single shift).

Structs§

Tables
Locking shift table plus single shift table used for one message.

Enums§

Language
National language identifier (23.038 §6.2.1.2.4), limited to the tables this module carries.

Constants§

ESC
Escape to the single shift (extension) table.

Functions§

choose_tables
Cheapest table pair able to encode text: the default tables if they work, otherwise the combination of the allowed locking and single shift tables (the default table is always allowed) with the fewest septets plus UDH cost (3 octets per national IE). None if nothing fits.
decode
Unpacked septets → text (23.038 §6.2.1.1). Unknown escape sequences show the locking-table character at that index; ESC ESC and a trailing lone ESC show a space. Bit 7 of every input byte is ignored.
encode
Text → unpacked septets. Err(c) names the first character with no mapping.
encode_char
Septets for one character: [code] or [ESC, code]. None if the character is in neither table.
is_encodable
pack
Pack septets into octets, LSB first, after fill_bits zero bits (0..=7; larger values are taken modulo 8). Used with fill_bits > 0 after a UDH (23.040 §9.2.3.24).
septet_len
Septet count of text, or None if it is not encodable with tables.
septets_in
Number of septets that fit in octets after fill_bits bits.
unpack
Unpack up to count septets starting after fill_bits bits. Returns fewer when the input runs out; never panics.