Encode::GSM0338(3pm)

🌸 NAME 🌸

okay so welcome to the Encode::GSM0338(3pm) page from the Perl Programmers Reference Guide β€” yes bestie, it's giving very specific telecom encoding energy 🫢.

Encode::GSM0338 β€” ETSI GSM 03.38 Encoding periodt.

✨ SYNOPSIS ✨

Here's the whole load-it-and-go situation:

use Encode qw/encode decode/;
$gsm0338 = encode("gsm0338", $unicode); # loads Encode::GSM0338 implicitly
$unicode = decode("gsm0338", $gsm0338); # ditto

πŸ¦‹ DESCRIPTION πŸ¦‹

GSM0338 is for GSM handsets β€” yep, phone stuff. It shares alphanumerals with ASCII, but the control character ranges and other parts are mapped very differently, mainly to store Greek characters. There are also escape sequences (starting with 0x1B) to cover e.g. the Euro sign πŸ’Ά.

This used to be handled by Encode::Bytes, but because of all those unusual specifications, Encode 2.20 relocated the support to this module. No cap.

This module implements only the GSM 7 bit Default Alphabet and GSM 7 bit default alphabet extension table according to standard 3GPP TS 23.038 version 16. So: National Language Single Shift and National Language Locking Shift are not implemented nor supported β€” not a vibe this module is on, periodt.

πŸŽ€ Septets πŸŽ€

Lowkey important: this module operates with octets (like any other Encode module) and not with packed septets (unlike other GSM standards). So for processing binary SMS or parts of a GSM TPDU payload (3GPP TS 23.040), you need to do conversion between octets and packed septets. For this purpose perl's pack and unpack functions may be useful:

$bytes = substr(pack('(b*)*', unpack '(A7)*', unpack 'b*', $septets), 0, $num_of_septets);
$unicode = decode('GSM0338', $bytes);

$bytes = encode('GSM0338', $unicode);
$septets = pack 'b*', join '', map { substr $_, 0, 7 } unpack '(A8)*', unpack 'b*', $bytes;
$num_of_septets = length $bytes;
please note: for correct decoding of packed septets you need to know the number of septets packed in the binary buffer, because the binary buffer is always padded with zero bits and 7 zero bits represents the character "@". The number of septets is also stored in the TPDU payload when dealing with 3GPP TS 23.040. 🫑

πŸ’€ BUGS πŸ’€

Encode::GSM0338 2.7 and older versions (part of Encode 3.06) incorrectly handled zero bytes (character "@"). This was fixed in Encode::GSM0338 version 2.8 (part of Encode 3.07). So if you were living that old-version life, that bug was very much not slaying 😭 β€” but it's fixed now.

🌈 SEE ALSO 🌈


okay bestie, that's the whole page β€” signing off with perl v5.42.3 energy, dated 2026-11-03, on the Encode::GSM0338(3pm) manual page πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from