Kakasi is a converter from Japanese with kanji to phonetic Japanese. Its documentation is sparse and I couldn't find any examples on the net that worked. So here's a note to myself for how I got it to work. It's pretty lame that it won't just handle utf8 by itself...
Sunday, January 10, 2010
echo イさんに本を貸しました。 | iconv -f utf8 -t euc-jp | kakasi -JHK -s -f | iconv -f euc-jp -t utf8 イ さんに 本[ほん] を 貸し[かし] ました 。Dropping the -f causes the kanji to be replaced entirely by their pronunciation, instead of having their pronunciation noted alongside them.