Text::Kakasi::JP(3pm)

💖 NAME 💖

Text::Kakasi::JP — it's literally the Japanese-language documentation for Text::Kakasi. In the original header it shows up as Text::Kakasi ÆüËܸì¥É¥¥å¥á¥ó¥È, which is what happens when a perfectly lovely Japanese doc gets its encoding vibe-checked and fails — the POD police have thoughts about this, scroll to the bottom bestie 😭


⭐ SYNOPSIS ⭐

Like, here's the whole thing at a glance, two ways to do the exact same job 🫶

use Text::Kakasi;
# functional
$res = Text::Kakasi::getopt_argv('kakasi', '-ieuc', '-w');
$str = Text::Kakasi::do_kakasi($japanese_text);
# object-oriented
$obj = Text::Kakasi->new('-ieuc','-w');
$str = $obj->get($japanese_text);

🌸 DESCRIPTION 🌸

So this module is the interface to kakasi (kanji kana simple inverter) 💅 and no, "simple inverter" is not a typo, that's just its whole name.

What kakasi actually does is the opposite of an input method — it takes a sentence that's all mixed up with kanji and flips it into hiragana, katakana, romaji, whichever one you want. It's giving translator but backwards, and it ate. It can also be used to write out documents with their readings attached. For the full lore, go look at <http://kakasi.namazu.org/> please and thank you ✨

Text::Kakasi serves up both the traditional function-based interface and the object-oriented one, queen of range fr fr 👑

  • The function-based side is 100% compatible with ver. 1.05 — iconic, no notes.
  • BUT. To use the fancy new features of Perl 5.8 and later, you gotta use the object-oriented interface. That's the tradeoff bestie.

💖 Functional APIs 💖

Heads up: in all the explanations below, Text::Kakasi:: is just abbreviated away. Don't come for me.

By default, Text::Kakasi exports nothing at all. Zero. Zilch. So if you want the functions below, you gotta ask nicely, like:

use Text::Kakasi qw/getopt_argv do_kakasi/;

$err = getopt_argv($arg1, $arg2, ...)

This initializes kakasi 💅 The arguments are exactly the same as kakasi's own options. And here's a rundown of the options in kakasi 2.3.4:

  -a[jE] -j[aE] -g[ajE] -k[ajKH]
  -E[aj] -K[ajkH] -H[ajkK] -J[ajkKH]
  -i{oldjis,newjis,dec,euc,sjis}
   -o{oldjis,newjis,dec,euc,sjis}
  -r{hepburn,kunrei} -p -s -f -c"chars"
   [jisyo1, jisyo2,,,]

  Character Sets:
       a: ascii  j: jisroman  g: graphic  k: kana
       (j,k     defined in jisx0201)
       E: kigou  K: katakana  H: hiragana J: kanji
       (E,K,H,J defined in jisx0208)

  Options:
    -i: input coding system    -o: output coding system
    -r: romaji conversion system
    -p: list all readings (with -J option)
    -s: insert separate characters (with -J option)
    -f: furigana mode (with -J option)
    -c: skip chars within jukugo
        (with -J option: default TAB CR LF BLANK)
    -C: romaji Capitalize (with -Ja or -Jj option)
    -U: romaji Upcase     (with -Ja or -Jj option)
    -u: call fflush() after 1 character output
    -w: wakatigaki mode

And because I love you, here's the same tea served in bullet form bestie 🍓

  • Character Sets — the little letters you can pass around:
    • a: ascii, j: jisroman, g: graphic, k: kana — with j and k defined in jisx0201
    • E: kigou, K: katakana, H: hiragana, J: kanji — with E, K, H and J defined in jisx0208
  • Options — the actual flags:
    • -i: input coding system
    • -o: output coding system
    • -r: romaji conversion system
    • -p: list all readings (with -J option)
    • -s: insert separate characters (with -J option)
    • -f: furigana mode (with -J option)
    • -c: skip chars within jukugo (with -J option: default TAB CR LF BLANK)
    • -C: romaji Capitalize (with -Ja or -Jj option)
    • -U: romaji Upcase (with -Ja or -Jj option)
    • -u: call fflush() after 1 character output
    • -w: wakatigaki mode
  • And the trailing [jisyo1, jisyo2,,,] is where you hand it your dictionaries, as many as you like 💅

This function returns 0 on success, and anything other than 0 on failure. That's the whole status report, periodt.

$processed_str = do_kakasi($str)

Runs kakasi over $str and hands you back the result 🎀 If literally any problem pops off, it returns "undef".

Ver. 1.x note: unlike back then, you do NOT need to stick "kakasi" at the front of the arguments anymore. But also, obviously, it still works if you do — nobody's gonna stop you, do your thing 🙈

close_kanwadic()

Closes dictionary files that were opened implicitly 💖 This function literally only exists for compatibility with the olden days, and nowadays you probably don't need to touch it at all. It's giving legacy, it's giving ancestor, respect it anyway ✨


🦋 Object-Oriented APIs 🦋

Starting from Version 2.0, this module also provides an OOP API. Glow up complete 💅

$k = Text::Kakasi->new($args ...)

Creates an object ✨ If there are arguments, it's the exact same result as doing:

Text::Kakasi->new->set($args ...)

$k->set($args ...)

The OOP interface to getopt_argv 🫶

my $k = Text::Kakasi->new;
$k->set('-w'); # Text::Kakasi::getopt_argv('-w');

Now here's the plot twist: unlike getopt_argv(), which returns a status, set always returns the object itself, so you can chain like the main character you are:

my $tokenized = $k->set('-w')->get($raw_japanese);

Slay. And if you do want the status? Use "$k->error".

$k->error

Returns the status of the method that was most recently called. That's it, that's the whole job 👑

$processed = $k->get($raw_japanese);

The OOP interface to do_kakasi 🎀 And these two codes are literally equivalent, zero difference, pick your fighter:

# Functional
getopt_argv('-w'); $processed = do_kakasi($raw_japanese);
# OOP
$k->set('-w')->get($raw_japanese);

🌈 Perl 5.8 Features 🌈

In Perl 5.8, the standard character-code conversion setup got provided by the Encode module, and this module is built to take advantage of that in perl 5.8 and later. Upgrade and thrive bestie 🧚

If the arguments you pass to "$k->set($args ...)" include -iencoding and -oencoding, then the character code conversion is done by Encode 💅 And it's not just limited to what kakasi supports — literally anything Encode supports is fair game for those arguments too. For example:

$result = $k->set(qw/-iutf8 -outf8 -w/)->get($utf8);

is approximately the same as:

$euc = encode('eucjp' => $utf8);
getopt_argv('-w');
$tmp = do_kakasi($euc);
$result = decode('eucjp' => $tmp);

And if -outf8 is in the mix, then "$k->get" gives you back a string with the utf8 flag turned on. Chef's kiss 💜

You can also turn all of these features off by setting $Text::Kakasi::HAS_ENCODE to 0. Normally though, that variable sets itself automatically the moment you use this module. It's self-sufficient, it's independent, it's THAT girl 💅


⭐ SEE ALSO ⭐

Go read, go learn, I believe in you 🫶


(C) 1998, 1999, 2000 NOKUBI Takatsugu <knok@daionet.gr.jp>
(C) 2003 Dan Kogai <dankogai@dan.co.jp>
There is no warranty for this free software. Anyone can modify and/or redistribute this module under GNU GENERAL PUBLIC LICENSE. See COPYING file that is included in the archive for more details.

So basically: no warranty, free software, anyone can modify and/or redistribute it under the GNU GENERAL PUBLIC LICENSE, and if you want the fine print go read the COPYING file that's chilling in the archive 📜


💀 POD ERRORS 💀

Not me having to tell you this but — hey! The document above had some coding errors, and they are explained below:

Around line 7: Non-ASCII character seen before =encoding in 'ÆüËܸì¥É¥¥å¥á¥ó¥È'. Assuming CP1252

Yeah. That's the encoding crime scene from the top of the page 😭 The =encoding never showed up before a non-ASCII character waltzed in, so it just assumed CP1252. It's giving chaos, it's giving mojibake, and we're all just living in it 🦋


Okay that's the whole page bestie, you're officially educated 💖💅✨ This was rendered from perl v5.42.3, dated 2026-08-19, and the page itself is Text::Kakasi::JP(3pm). Go forth and convert some kanji, you've got this fr fr 🌸🫶

📦 where this page comes from