Encode::GSM0338(3perl)

πŸ’– Encode::GSM0338 β€” the ETSI GSM 03.38 Encoding page πŸ’–

okay bestie, this is Encode::GSM0338, living in the Perl Programmers Reference Guide, and she is so niche but so important. let's get into it πŸŽ€


✨ NAME ✨

Encode::GSM0338 β€” ETSI GSM 03.38 Encoding, no cap πŸ’…


🌸 SYNOPSIS 🌸

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

see how encode and decode just do it? and the # loads Encode::GSM0338 implicitly bit? yeah, she loads herself in, no use Encode::GSM0338 needed, main character energy fr fr πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

so GSM0338 is for GSM handsets πŸ“±. and yes, she shares alphanumerals with ASCII, but do NOT get it twisted β€” the control character ranges and other parts are mapped very differently, mainly so she can store Greek characters. she's multilingual like that πŸ¦‹

there are also escape sequences (they start with 0x1B) to cover stuff like the Euro sign πŸ’Ά. iykyk.

this used to be handled by Encode::Bytes, but because of all those unusual specifications, Encode 2.20 relocated the support to this module. glow up era ✨

lowkey important: this module implements only GSM 7 bit Default Alphabet and GSM 7 bit default alphabet extension table according to standard 3GPP TS 23.038 version 16. therefore National Language Single Shift and National Language Locking Shift are not implemented nor supported. not a vibe, just a fact πŸ™ˆ

πŸŽ€ Septets πŸŽ€

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

$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 must 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 character "@" 😭. the number of septets is also stored in TPDU payload when dealing with 3GPP TS 23.040, so it's there, just sayin'.

πŸ’€ 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). she said "not anymore" and meant it πŸ’…βœ…


🌈 SEE ALSO 🌈


and that's the whole page, bestie 🫢 this was Encode::GSM0338(3perl) from perl v5.44.0, dated 2026-10-17 β€” go forth and encode your septets responsibly, ily πŸ’–πŸ§šβ­

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms