in reply to utf8 output with 5.8
In 5.8 you can (and should) specify which encoding perl should use when writing.
By default perl5.8 will assume you want latin1 output (but warn and then output in utf8 those strings that do not fit in latin1).
If you switch your environment to utf8 with something like
then you should get the output you expected.env LC_CTYPE=en_US.UTF-8 perl -e ...
A different way to do it (TIMTOWTDI) is to explicitly switch STDOUT to a different encoding using the newly repurposed binmode():
binmode STDOUT, ':utf8';
A third way is using the new use open pragma:
use open ':utf8', ':std';
So to get your one-liner to work, it becomes:
perl -Mopen=:utf8,:std -e '$c="f6"; $u=pack("U",hex($c)); print $u, "\ +x{f6}"' | od -tx1
I'm sure you'll be able to find your way to the documentation for these new perl5.8 features. A good start is the perluniintro manpage.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: utf8 output with 5.8
by axelrose (Scribe) on Oct 30, 2002 at 10:10 UTC |
In Section
Seekers of Perl Wisdom