Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: utf8 output with 5.8

by axelrose (Scribe)
on Oct 30, 2002 at 22:21 UTC ( #209260=note: print w/replies, xml ) Need Help??

in reply to utf8 output with 5.8

Within "perluniintro.pod" I found this:

Note that \x.. (no {} and only two hexadecimal digits), \x{...}, and
chr(...) for arguments less than 0x100 (decimal 256) generate an
eight-bit character for backward compatibility with older Perls.  For
arguments of 0x100 or more, Unicode characters are always produced. If
you want to force the production of Unicode characters regardless of the
numeric value, use pack("U", ...) instead of \x.., \x{...}, or chr().

This explains why "\x{f6}" won't produce utf8 output.
Nonetheless the pack( "U", hex( "f6" ) ) I used originally should spit out a two byte sequence, shouldn't it?

Replies are listed 'Best First'.
Re: Re: utf8 output with 5.8
by axelrose (Scribe) on Nov 26, 2002 at 17:18 UTC
    to answer myself: it depends on the LANG environment
    [rose@localhost rose]$ export LANG=C [rose@localhost rose]$ perl -e 'print "\x{f6}"' | od -tx1 0000000 f6 0000001 [rose@localhost rose]$ perl -e 'print pack "U", 0xf6 ' | od -tx1 0000000 f6 0000001 [rose@localhost rose]$ export LANG=de_DE.UTF-8 [rose@localhost rose]$ perl -e 'print pack "U", 0xf6 ' | od -tx1 0000000 c3 b6 0000002 [rose@localhost rose]$ perl -e 'print "\x{f6}"' | od -tx1 0000000 c3 b6 0000002

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://209260]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2023-11-29 12:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found