in reply to Re: Help with Encode::JP
in thread Help with Encode::JP

$char_string = decode("euc-jp", $jp_bytes); $utf8_bytes = encode("utf8", $char_string);

No, I think the OP's issue is that he's having trouble converting the utf8 encoding (as stored to and fetched from the database) back into "euc-jp", because (for example), maybe that's how the data needs to be displayed.

Converting to utf8_bytes is kind of useless in this context.

Replies are listed 'Best First'.
Re^3: Help with Encode::JP
by ikegami (Patriarch) on Sep 19, 2006 at 15:38 UTC

    Sounds to me likes he wants to do both. I assumed he could figure out that all he needs to do to go in the other direction is to replace euc-jp for utf8 and vice-versa.

    $char_string = decode("utf8", $utf8_bytes); $jp_bytes = encode("euc-jp", $char_string);

    or

    $jp_bytes = encode("euc-jp", decode("utf8", $utf8_bytes));

    or

    $jp_bytes = from_to($utf8_bytes, "utf8", "euc-jp");

    or

    $char_string = decode("utf8", $utf8_bytes); binmode FH, ":encoding(euc-jp)"; print FH $char_string;