Encode::JP(3perl)

πŸ’– Encode::JP πŸ’–

okay bestie, so this is the Encode::JP page from the Perl Programmers Reference Guide β€” it's the module that handles Japanese encodings and honestly? it's a whole vibe. let's get into it ✨


🌸 NAME 🌸

Encode::JP β€” Japanese Encodings. yes that's the whole thing. it does what it says on the tin, queen πŸ‘‘


✨ SYNOPSIS ✨

here's the whole entire vibe, bestie:

use Encode qw/encode decode/;
$euc_jp = encode("euc-jp", $utf8);   # loads Encode::JP implicitly
$utf8   = decode("euc-jp", $euc_jp); # ditto

see how you didn't even have to ask for it? Encode::JP just shows up. main character energy fr πŸ’…


πŸŽ€ ABSTRACT πŸŽ€

so this module implements Japanese charset encodings, and the whole roster is as follows. no cap, here's everybody:

  • euc-jp β€” aliases: /\beuc.*jp$/i, /\bjp.*euc/i, /\bujis$/i β€” this one's EUC (Extended Unix Character) πŸ¦‹
  • shiftjis β€” aliases: /\bshift.*jis$/i, /\bsjis$/i β€” Shift JIS, aka MS Kanji ✨
  • 7bit-jis β€” alias: /\bjis$/i β€” 7bit JIS
  • iso-2022-jp β€” no aliases, it's just ISO-2022-JP [RFC1468], which is = 7bit JIS with all Halfwidth Kana converted to Fullwidth πŸ’œ
  • iso-2022-jp-1 β€” ISO-2022-JP-1 [RFC2237] = ISO-2022-JP with JIS X 0212-1990 support. See below πŸ‘€
  • MacJapanese β€” Shift JIS + Apple vendor mappings 🍎
  • cp932 β€” alias: /\bwindows-31j$/i β€” Code Page 932 = Shift JIS + MS/IBM vendor mappings πŸͺŸ
  • jis0201-raw β€” JIS0201, raw format
  • jis0208-raw β€” JIS0208, raw format
  • jis0212-raw β€” JIS0212, raw format

and that's the entire lineup, periodt 🌈


πŸ’œ DESCRIPTION πŸ’œ

ngl if you wanna find out how to use this module in detail, go read Encode. that's the actual full manual, this one's just the Japanese-flavored chapter 🫢

🌟 Note on ISO-2022-JP(-1)? 🌟

okay so this is the part where it gets a little spicy πŸ”₯

ISO-2022-JP-1 (RFC2237) is a superset of ISO-2022-JP (RFC1468), and what it adds is support for JIS X 0212-1990. what that means for you is: you can run the same code to decode to utf8, but not the other way around. so like:

$utf8 = decode('iso-2022-jp-1', $stream);

and

$utf8 = decode('iso-2022-jp',   $stream);

both give you the exact same result, bestie. same output, no diff. but then:

$with_0212 = encode('iso-2022-jp-1', $utf8);

is now different from

$without_0212 = encode('iso-2022-jp', $utf8 );

and in that latter case β€” the iso-2022-jp one β€” any characters that map to 0212 get converted first to U+3013 (0xA2AE in EUC-JP; that's a white square, also known as 'Tofu' or 'geta mark' β€” yes the tofu has a whole nickname 😭) and then handed off to the decoding engine.

and lowkey important: U+FFFD is not used here, because the goal is to preserve the text layout as much as possible. so if you were expecting the classic replacement char, bestie... you're not getting it πŸ™ˆ


πŸ’€ BUGS πŸ’€

heads up: the ASCII region (0x00-0x7f) is preserved for all encodings, even though that conflicts with mappings by the Unicode Consortium. so yeah. it is what it is β€” documented, known, and still shipped πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘

  • Encode

and that's the whole page, bestie πŸŽ€ this was Encode::JP(3perl) from the Perl Programmers Reference Guide, perl v5.44.0, dated 2026-10-17. go slay some charset conversions, you've totally got this πŸ¦‹βœ¨πŸ’–

πŸ“¦ 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