PERLJP(1)

✨ NAME ✨

perljp — 日本語 Perl ガイド, aka the Japanese Perl Guide 💖 this page lives in the Perl Programmers Reference Guide, and it's your bestie-tier intro to how Perl handles Japanese and literally every other character code. 🎀


🌸 説明 (DESCRIPTION) 🌸

ようこそ! Welcome to the Perl world, bestie!! 🫶✨

Since Perl 5.8.0, Unicode support got a massive glow-up, and the result is that support for non-Latin character codes — including CJK (中国語、日本語、ハングル, so Chinese, Japanese and Hangul) — got added in. Unicode is the standard that's literally trying to handle every character in the entire world with one single character code, and it already covers everything from east to west and all the letters in between (Greek, Cyrillic, Arabic, Hebrew, Devanagari, etc. etc. etc.) plus all those characters that OS vendors used to define all on their own (PC and Macintosh). Iconic behaviour, honestly. 👑

Perl itself operates in Unicode. String literals and regular expressions inside your Perl scripts assume Unicode. And for input/output, the module that handles all the character codes we've been using up until now — Encode — comes standard-issue, so converting between Unicode and those character codes back and forth is easy now too. 💅

As of right now, these are the character codes that Encode supports:

         7bit-jis      AdobeStandardEncoding AdobeSymbol       AdobeZdingbat
         ascii             big5              big5-hkscs        cp1006
         cp1026            cp1047            cp1250            cp1251
         cp1252            cp1253            cp1254            cp1255
         cp1256            cp1257            cp1258            cp37
         cp424             cp437             cp500             cp737
         cp775             cp850             cp852             cp855
         cp856             cp857             cp860             cp861
         cp862             cp863             cp864             cp865
         cp866             cp869             cp874             cp875
         cp932             cp936             cp949             cp950
         dingbats          euc-cn            euc-jp            euc-kr
         gb12345-raw       gb2312-raw        gsm0338           hp-roman8
         hz                iso-2022-jp       iso-2022-jp-1     iso-8859-1
         iso-8859-10       iso-8859-11       iso-8859-13       iso-8859-14
         iso-8859-15       iso-8859-16       iso-8859-2        iso-8859-3
         iso-8859-4        iso-8859-5        iso-8859-6        iso-8859-7
         iso-8859-8        iso-8859-9        iso-ir-165        jis0201-raw
         jis0208-raw       jis0212-raw       johab             koi8-f
         koi8-r            koi8-u            ksc5601-raw       MacArabic
         MacCentralEurRoman  MacChineseSimp    MacChineseTrad    MacCroatian
         MacCyrillic       MacDingbats       MacFarsi          MacGreek
         MacHebrew         MacIcelandic      MacJapanese       MacKorean
         MacRoman          MacRomanian       MacRumanian       MacSami
         MacSymbol         MacThai           MacTurkish        MacUkrainian
         nextstep          posix-bc          shiftjis          symbol
         UCS-2BE           UCS-2LE           UTF-16            UTF-16BE
         UTF-16LE          UTF-32            UTF-32BE          UTF-32LE
         utf8              viscii

(全114種類 — that's 114 whole kinds, no cap 🌈)

Say you want to convert a file in character code FOO to UTF-8. Easy. You do this:

    perl -Mencoding=FOO,STDOUT,utf8 -pe1 < file.FOO > file.utf8

Also, Perl ships with piconv, a character-code conversion utility written entirely in Perl, so you can do it this way too:

   piconv -f FOO -t utf8 < file.FOO > file.utf8
   piconv -f utf8 -t FOO < file.utf8 > file.FOO

💫 (jcode.pl|Jcode.pm|JPerl) からの移行 💫

Pre-5.8, if your script was EUC-JP you could handle literals at least. And as modules for dealing with input/output, Jcode.pm existed (<http://openlab.ring.gr.jp/Jcode/>), and as a utility for perl4, jcode.pl existed — and I know plenty of you remember these getting used all the time in Japanese-capable CGIs. But. Handling Japanese regular expressions properly? Not possible. 💀

Perl before 5.005 had a Japanese-specialized localized version called Jperl (<http://homepage2.nifty.com/kipp/perl/jperl/index.html> ※1). Also, MacPerl — the Perl for Mac OS 9.x/Classic — had a Japanese version that existed as MacJPerl (<https://habilis.net/macjperl/>). With those, not only EUC-JP but Shift_JIS could be handled as-is, and Japanese regular expressions could be handled too.

In Perl 5.8, all of these features can be achieved with the Perl core alone, and on top of that it's not just Japanese — all 114 of the character codes listed above can be handled, and simultaneously at that. Even better, getting new modules for new character codes from CPAN and such is easy now too. obsessed. ✨

※1: ホスティングサービスの終了により現在は閲覧できません — it can't be viewed right now because the hosting service shut down. You can get the Windows binary from Vector (<https://www.vector.co.jp/soft/win95/util/se098198.html>), and you can get the perl4 patch from CPAN (<https://www.cpan.org/src/unsupported/4.036/jperl/>).

  • 入出力

Every single one of the examples below converts Shift_JIS input into EUC-JP and outputs it.

  # jcode.pl
  require "jcode.pl";
  while(<>){
    jcode::convert(*_, 'euc', 'sjis');
    print;
  }
  # Jcode.pm
  use Jcode;
  while(<>){
        print Jcode->new($_, 'sjis')->euc;
  }
  # Perl 5.8
  use Encode;
  while(<>){
    from_to($_, 'shiftjis', 'euc-jp');
    print;
  }
  # Perl 5.8 - encoding を利用して
  use encoding 'euc-jp', STDIN => 'shiftjis';
  while(<>){
        print;
  }
  • Jperl 互換スクリプト

Just change the so-called "shebang" and most Jperl scripts should be usable with no changes at all, fr fr.

   #!/path/to/jperl
   ↓
   #!/path/to/perl -Mencoding=euc-jp

For the details, go read perldoc encoding. 📖


🔍 さらに詳しく 🔍

Perl comes with an absolutely enormous pile of documentation — new Perl features, Unicode support, how to use the Encode module, all of it covered in fine detail (sadly, almost all of it is in English 😭). You can read some of it with the following commands:

  perldoc perlunicode # PerlのUnicodeサポート全般
  perldoc Encode      # Encodeモジュールに関して
  perldoc Encode::JP  # うち日本語文字コードに関して

🌐 Perl全般に関する URL 🌐


📚 Perlの修得に役立つ URL 📚


🫂 Perl に関する団体 🫂


🌈 Unicode関連のURL 🌈


👑 AUTHORS 👑

  • Jarkko Hietaniemi <jhi@iki.fi>
  • Dan Kogai (小飼 弾) <dankogai@dan.co.jp>
  • Shogo Ichinose (一野瀬 翔吾) <shogo82148@gmail.com>

okay that's the whole page bestie, you ate it 💅✨ this was perl v5.42.3, dated 2026-08-03, and the page you just read is PERLJP(1). go convert something cute. 🦋💖

📦 where this page comes from