I am trying to use the Kakasi kanji/hiragana/katakana to roomaji converter, as an aid to learning kanji pronunciation within specific sentences. I am using command and parameters:

kakasi -Ja -Ha -Ka -Ea -s

For example, converting today's date gives:

$ echo "7月31日" | kakasi -Ja -Ha -Ka -Ea -s 
7 shin ?? 1 ka �

There is clearly a configuration error, that I think comes from the input encoding (UTF-8) not being correctly understood by the tool.

Could anybody with experience on this matter please advise on how to either tell kakasi to accept Unicode input, or suggest an alternative open-source tool for conversion that works better? (Please, no Windows software.)

  • 1
    I think this question is off-topic for the main site and should be migrated to our meta page. Other people are using kakasi by converting Unicode to SHIFT-JIS before using kakasi on a string (and converting back afterwards): w3facility.org/question/japanese-to-romaji-with-kakasi Maybe kakasi just accepts SHIFT-JIS?
    – Earthliŋ Mod
    Commented Jul 31, 2015 at 16:16
  • 1
    @Earthliŋ OK, have flagged for migration. Thanks for the link, it doesn't quite solve my problem but confirms I have a problem with encoding.
    Commented Jul 31, 2015 at 16:21
  • 2
    You could always convert to another encoding with iconv. I've been using some morphological analyzers as well and sth. like echo ... | iconv -f ... -t ... | kakasi might be easier than recompiling/rebuilding dictionaries etc.
    – blutorange
    Commented Jul 31, 2015 at 17:12
  • As an aside, roumaji is a seriously weird way to romanize ローマ字. This word is never written with a う in kana, and it's not pronounced with a /u/ in speech.
    – user1478
    Commented Aug 1, 2015 at 0:38
  • @snailboat You should see the spelling mistakes native English speakers make in English on other SE sites - and then perhaps be slightly less pedantic. ;-) Correction appreciated, anyway, thanks.
    Commented Aug 1, 2015 at 7:09

1 Answer 1


Thanks to comments by @Earthliŋ and @blutorange (recognition where recognition is due), the combination of iconv with kakasi has finally worked. Initial convertion from Unicode to Shift-JIS is required, and performed using:

$ echo "7月31日" | iconv -f utf8 -t shift-jis | kakasi -Ja -Ha -Ka -Ea -s 

7 gatsu 31 nichi

Conversion back in the other direction is not needed when output is roumaji, since the basic characters have low ASCII values that are identical under all encodings. If necessary, conversion from Shift-JIS back to Unicode can be performed with:

$ echo "7月31日" | iconv -f utf8 -t shift-jis | kakasi -Ja -Ha -Ka -Ea -s | iconv -f shift-jis -t utf8

7 gatsu 31 nichi

For instance, to convert into Hiragana:

$ echo "7月31日" | iconv -f utf8 -t shift-jis | kakasi -JH -KH -Ea -s | iconv -f shift-jis -t utf8

7 がつ 31 にち


As pointed out by @oals in the comments, newer versions of kakasi have the little documented parameters -iutf8 and -outf8 to specify Unicode encoding for either input or output. The above conversion to Hiragana can then be more efficiently performed using:

$ echo "7月31日" | kakasi -JH -KH -Ea -s -iutf8 -outf8

7 がつ 31 にち

Thanks for your help.

  • 1
    My kakasi has an -iutf8 option.
    – oals
    Commented Aug 1, 2015 at 6:53
  • @oals That is precisely what I was looking for, and could not find in the manual page or documented in the examples. Does it also make the output UTF-8?
    Commented Aug 1, 2015 at 7:12
  • I think it does, but there's a switch, -outf8, to explicitly set the output encoding.
    – oals
    Commented Aug 1, 2015 at 7:44
  • @oals OK, thanks for commenting. Have tested your indications and built them into the answer.
    Commented Aug 1, 2015 at 10:05
  • If I do echo "退屈であくびばっかしていた毎日" | iconv -f utf8 -t eucjp | kakasi -i euc -Ha -Ka -Ja -Ea -ka -s I get taikutsu deakubibakkashiteita mainichi but adding -iutf8 -outf8 it outputs KA kutsu deakubibakkashiteita. Why? Commented Oct 17, 2017 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .