perl-unicode

Re: Should Encode::encode affect the original string? -- Solved!

2007-07-07 06:34:30
On Fri, Jul 06, 2007 at 09:06:20AM -0400, Stephen J. Smith wrote:
Unexpected results when CHECK is 1:

$ perl -MEncode -e '$s='hi';Encode::encode("UTF-8", $s, 1);print "($s)\n"'
()

Looking over the Encode.pm source I spotted LEAVE_SRC, which I then
found in the documentation.  Set it if you want the original scalar left
alone:

$ perl -M'Encode ":fallback_all"' -e '$s='hi';Encode::encode("UTF-8",
$s, Encode::FB_CROAK | Encode::LEAVE_SRC);print "($s)\n"'
(hi)

-Stephen

<Prev in Thread] Current Thread [Next in Thread>