perl-unicode

\x (backslash x) weirdness in perl 5.6.0

2001-01-15 04:57:10
Folks:

Just experimenting with the \x notation and found
some surprises.

1) Seems like print "\x{0041}"; works as expected (gives 'A'), but 
"\x{$s}", where $s is the string hex value '0041', first
gives the warning below then a blank value.

Any ideas what I'm doing wrong?

# perl u.pl >x
Illegal hexadecimal digit '$' ignored at u.pl line 10 (#1)
    (W digit) You may have tried to use a character other than 0 - 9 or
    A - F, a - f in a hexadecimal number.  Interpretation of the hexadecimal
    number stopped before the illegal character.
    
# cat u.pl

use strict;
use diagnostics;

use utf8;

   foreach (65 .. 255) {
      my $s = sprintf("%04x", $_);

      print "\$_ = $_, s = $s, u = \x{$s}\n";
   }

2) Looks like "\x{0041}" is understood by the parser, but
not the bare \x{0041} (error) or '\x{0041}' (not
interpolated into a unicode value. Comments?

James.


And of course:

# perl -v

This is perl, v5.6.0 built for i586-linux

Copyright 1987-2000, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

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