Encode::ISO2022(3)
β¨ Encode::ISO2022 β¨
okay bestie, so this is Encode::ISO2022, one of the User Contributed Perl Documentation pages, and it's the whole ISO/IEC 2022 character encoding scheme situation π . Like, it's giving encoding scheme, and you're gonna want to sit down for this one π«Ά.
πΈ NAME πΈ
Encode::ISO2022 β the ISO/IEC 2022 character encoding scheme, no cap.
π SYNOPSIS π
so here's the vibe, you make a package and inherit from it:
package FooEncoding;
use base qw(Encode::ISO2022);
__PACKAGE__->Define(
Name => 'foo-encoding',
CCS => [ {...CCS one...}, {...CCS two...}, ....]
);
like, that's it, that's the whole flex β¨.
π DESCRIPTION π
This module hands you a character encoding scheme (that's a CES, iykyk) that switches between a whole set of multiple coded character sets (those are your CCSs, plural, a whole squad π).
There's a class method Define() and bestie it takes these arguments:
Alias => REGEXβ a regex that represents the alias of this encoding, if there even is one. optional, no pressure πName => STRINGβ the name of this encoding as an Encode::Encoding object. Mandatory. you literally cannot skip this one π¨CCS => [ FEATURE, FEATURE, ...]β the list of features that define the CCSs this encoding uses. Also mandatory. Every single item in that list is a hash reference holding these little cuties:bytes => NUMBERβ how many bytes it takes to represent each character. The default is1. one byte, one icon πcl => BOOLEANβ if you set a true value, this CCS includes a map to/from code points between0/0and1/15. There should be exactly one CCS with this flag, and its job is to reset broken designation. yes, its whole personality is fixing the mess πdec_only => BOOLEANβ if true, this CCS gets used only for decoding. it's shy, it doesn't encode, respect that πencoding => STRING | ENCODINGβ an Encode::Encoding object used as the CCS, or just its name. Mandatory. and listen, the encodings used for CCS must provide "raw" conversion. meaning: they have to be stateless, and they have to be fixed-length conversion over94^nor96^ncode tables.Encode::ISO2022::CCSlists all the available CCSs, so go look there if you're nosy πg => STRINGg_init => STRINGβ which working set this CCS may be designated to:'g0','g1','g2'or'g3'.
If g_init is set, this CCS gets designated implicitly at the beginning of conversion, and explicitly at the end of conversion. the way it shows up at the start AND the end, main character energy β¨
If g or g_init is set and neither ls nor ss is set, this CCS will be invoked when it's designated.
If neither g, g_init, ls nor ss is set, this CCS is invoked always. it's everywhere. it's in every conversation. periodt π
g_seq => STRINGβ the escape sequence to designate this CCS, if it can even be designated explicitly.gr => BOOLEANβ if true, this CCS gets invoked to GR using a 7-bit conversion table π₯ls => STRINGss => STRINGβ an escape sequence or control character to invoke this CCS, if it should be invoked explicitly.
If ls is set, this CCS is invoked by locking-shift. If ss is set, it's invoked by single-shift. two different entrances to the same party π
range => STRINGβ the possible range of encoded bytes. The general values are'\x21-\x7E','\x20-\x7F','\xA1-\xFE'or'\xA0-\xFF'. This one is required for multibyte CCSs so they can detect broken multibyte sequences. it's the vibe check for your bytes π
LineInit => BOOLEANβ if it's true, the designation and invokation states get initialized at the beginning of lines. fresh start, new line, new me π¦SubChar => STRINGβ the Unicode string to be used for the substitution character. your little stand-in π
And if you wanna know more about how to actually use this module, the source of Encode::ISO2022JP2 might just be the example you need. go read it, it's the blueprint bestie π
β οΈ CAVEATS β οΈ
okay so real talk, and I need you to hear me on this one:
This module implements a small subset of the features defined by ISO/IEC 2022. Each encoding recognizes only several predefined designation and invokation functions. It can handle a limited number of coded character sets. Variable length multibyte coded character sets aren't supported. And so on. π
like... it's not the full thing. it's the highlight reel. don't come for me when your wild custom CCS doesn't work π
π SEE ALSO π
ISO/IEC 2022 Information technology - Character code structure and extension techniques.Encode,Encode::ISO2022::CCS.
π AUTHOR π
Hatuka*nezumi - IKEDA Soji, <nezumi@cpan.org> β an actual legend π«Ά
π COPYRIGHT AND LICENSE π
Copyright (C) 2013 by Hatuka*nezumi - IKEDA Soji
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page bestie π β brought to you by perl v5.42.0, dated 2025-07-25, slaying under the name Encode::ISO2022(3). go forth and encode, you absolute icon β
π¦ where this page comes from
- fedora 43: perl-Encode-ISO2022 0.04-34.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms