GaijinPunch has asked for the wisdom of the Perl Monks concerning the following question:

Okay, I posted a thread last week and the issue wasn't resolved... I think my code was misunderstood. If anyone wants to take a look, here's the thread.
http://www.perlmonks.org/index.pl?node_id=478486
In that thread, I was told "Kakasi doesn't do anything w/ an ASCII based string." Well, obviously. I wasn't passing it one. :/

Code below attmpets OOP style and non-OOP. I assume it's a problem w/ one of the options, but I've tried more than a few different combinations. FYI $str holds an EUC encoded kanji. Coincidentally, so does $jpn and $nstr.
#!/usr/bin/perl # # use strict; use warnings; use Text::Kakasi; open ( OUT, ">poo" ) || die $!; my $str = "ËâË¡"; my $k = Text::Kakasi->new('-JH','-c','-w','-i euc','-o euc'); $k->set('-w', '-c', '-JH', '-i euc', '-o euc'); my $jpn = $k->get($str); print OUT "$str = $jpn ". "\n"; print OUT "error = " . $k->error . "\n"; my $res = Text::Kakasi::getopt_argv('-JH', '-c', '-w'); my $nstr = Text::Kakasi::do_kakasi($str); print OUT "jpn = $nstr\n";

Replies are listed 'Best First'.
Re: Once again, Kakasi
by dave_the_m (Monsignor) on Aug 01, 2005 at 01:06 UTC
    Oh for [deity of choice]'s sake. You ignore all the suggestions in the previous thread, start a new thread, then in the new thread tell us exactly zero about how the code is now failing, what output it produces, what output you expect, what results you had from trying people's previous suggestions, etc etc.

    Dave.

      Did you read my whole post?

      "FYI $str holds an EUC encoded kanji. Coincidentally, so does $jpn and $nstr."

      In other words, the output is the exact same as the input. I needed people to see the thread, hence I didn't reply to the old one. Doesn't push it to the top AFAIK. Sorry if that got your panties all in a bunch.
        "FYI $str holds an EUC encoded kanji. Coincidentally, so does $jpn and $nstr."

        Yes... "is that good or is it whack?" :-) What, exactly is the problem: i.e. what do you expect, and in what way does the problemgram fail to fulfill your expectations? I note that you are explicitly asking for euc input AND output.

        Please also use [id://XXXXX] notations to make a link to your previous question, which appears to have some useful answers already, so it would also help if you explained why those answers don't work for you.

        update: By the way, by the description in your previous node, I would guess you want something equivalent to

        > kakasi -w -JH -i euc -o euc
        which does all kinds of funny things to your input $str, but since I run a unicode terminal and don't know japanese, that's about as far as I can help you with the specific options. Running kakasi directly from the commandline seems to be a quicker way of trying out the options, though.

      I'm using Kakasi in conjunction with JMdict from (sorry) PHP here: http://kotoba.tremicom.com/