encoding the EUC to utf8 is a breeze.
$string = decode("euc-jp", $string);
Something's wrong when *decode* is used to *encode*.
UNICODE is a character set, not an encoding. You cannot store something in UNICODE format (as you claim), since there is no such thing. UNICODE characters need to be encoded in order to be stored. utf8 is a particularly convenient *encoding* for storing UNICODE characters.
Perl strings works in a similar way. It actually has two kinds of strings. Strings of bytes, and strings of characters. Encoded strings (euc-jp, utf8, etc) are strings of bytes, whereas strings of characters cannot be stored without first being encoded.
If you wish to store a euc-jp string as utf8, you wish to convert from one encoding to another.
$char_string = decode("euc-jp", $jp_bytes); $utf8_bytes = encode("utf8", $char_string);
or (U)
$utf8_bytes = encode("utf8", decode("euc-jp", $jp_bytes));
or
$utf8_bytes = from_to($jp_bytes, "euc-jp", "utf8");
or (U)
$char_string = decode("euc-jp", $jp_bytes); binmode FH, ":encoding(euc-jp)"; print FH $char_string;
In reply to Re: Help with Encode::JP
by ikegami
in thread Help with Encode::JP
by GaijinPunch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |