Encode::ISO2022(3)

πŸ“¦
version 0.04 Β· 2 versions
, in fedora 43

✨ 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 is 1. one byte, one icon πŸ’…
    • cl => BOOLEAN β€” if you set a true value, this CCS includes a map to/from code points between 0/0 and 1/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 over 94^n or 96^n code tables. Encode::ISO2022::CCS lists all the available CCSs, so go look there if you're nosy πŸ‘€
    • g => STRING
    • g_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 => STRING
  • ss => 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 (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