perl-unicode

Re: do{use utf8; ...}

1998-10-13 13:05:43
On 13 Oct 1998 20:30:25 +0200, Gisle Aas wrote:
Another one:

  $ perl -le 'print unpack("H*", join("", map do{use utf8; chr($_)}, 0x7F, 0x
FF, 0xFFF))'
  7fffff

It does not look like it is the UTF-8 version of chr() which is used
above, as the result is the same if we take out use utf8:

  $ perl -le 'print unpack("H*", join("", map do{chr($_)}, 0x7F, 0xFF, 0xFFF)
)'
  7fffff

and we get what we expect when put it outside:

  $ perl -le 'use utf8; print unpack("H*", join("", map do{chr($_)}, 0x7F, 0x
FF, 0xFFF))'
  7fc3bfe0bfbf

The first thing I tried was actually:

  map { use utf8; chr($_); } ...

but I was told: "use" not allowed in expression at...
What would it take to make that one legal?

Doubling the curlies should make it work.

 - Sarathy.
   gsar(_at_)engin(_dot_)umich(_dot_)edu

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