ut8 madness

Marc Lehmann schmorp at schmorp.de
Fri Mar 30 16:47:08 CEST 2012


On Thu, Mar 29, 2012 at 11:00:14PM -0700, gleeco <gleeco at gmail.com> wrote:
> question is more in the world of common::sense and utf8, but i'm seeing
> this in AE, so am seeking clarification/hints here on this list.

first, we need to clarify what you mean with utf8 - perl *internally* has
an utf8 flag, but that doesn't make the perl value itself utf-8. I assume you
are talking of the internal flag.

> Does Perl tag a whole data structure non-utf8 if part of it is not?

No.

> What happens in complex data structures with some part that is not utf8?

Some part is not utf-8 in that case.

> # later
> print JSON::XS->new->encode( \%data );  # broken!

Here you create a unicode string and then print it - but you cannot print
unicode to a filehandle, because filehandles need octets, so you need to
encode them somehow. You can mark stdout for auto-encoding, but did you do
so?

Try:

  print JSON::XS->new->utf8->encode( \%data );  # broken!

and see if that makes any difference.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list