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 π
- 3GPP TS 23.038 β
https://www.3gpp.org/dynareport/23038.htm - ETSI TS 123 038 V16.0.0 (2020-07) β
https://www.etsi.org/deliver/etsi_ts/123000_123099/123038/16.00.00_60/ts_123038v160000p.pdf Encode
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