develooper Front page | perl.perl5.porters | Postings from August 2013

Re: [perl #119239] started out as doc clarification needed in 'eval...but...

Thread Previous | Thread Next
Eric Brine
August 15, 2013 20:32
Re: [perl #119239] started out as doc clarification needed in 'eval...but...
Message ID:
On Thu, Aug 15, 2013 at 3:43 PM, Linda Walsh via RT <> wrote:

> Points) A) - "(to myself as much as anyone)" - use utf8 only applies to
> source code not content strings, so my wonderings why the Japanese
> INU(dog) YA(night) SHA(dividing point) came out "ok"

$ perl -Mutf8 -E'say "\x{72AC}\x{591C}\x{53C9}"'
Wide character in say at -e line 1.

File handles take bytes unless you arrange for an encoding layer to provide
those bytes. That error message is a polite way of saying "I was able to
detect that you gave me garbage, and I guessed at what you wanted".

Now lets look at the following:

$ perl -Mutf8 -E'say "\x51\x75\x65\x65\x6E\x73\x72\xFF\x63\x68\x65"'

Perl issued no error message because you provided bytes (values in 0..255)
as expected. Perl has no way to know you meant to output UTF-8.

- Eric

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About