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

Re^2: Bug : eval and accent

by SFLEX (Chaplain)
on Nov 16, 2007 at 12:30 UTC ( [id://651179]=note: print w/replies, xml ) Need Help??


in reply to Re: Bug : eval and accent
in thread Bug : eval and accent

your code does not work for me on "Perl ActiveState v5.8.8 built for MSWin32-x86-multi-thread OS Windows XP"
Im getting Error "Unrecognized character \xE9 at Untitled line 6"
I wounder if this is an ActiveState issue.

Replies are listed 'Best First'.
Re^3: Bug : eval and accent
by graff (Chancellor) on Nov 16, 2007 at 12:52 UTC
    That error would arise if the file containing the script is not written/stored as utf8 data -- the accented character would need to be a two byte sequence 0xc3 0xa9 in order to be the utf8 version of é.

    0xE9 is the cp1252/iso-8859-1 (single-byte) version, and having that form of the character in a script file that also has "use utf8" is a problem with the file, not with perl.

Re^3: Bug : eval and accent
by jbert (Priest) on Nov 16, 2007 at 12:56 UTC
    Hmm...are you sure the file in in utf8? E9 is latin1 for e-acute.

    Can you dump the hex values and check? (or just try code below).

    If your users are entering latin-1, then you could use the Encode module to shift the script to utf8.

    #!/usr/bin/perl use strict; use warnings; use Encode; use utf8; my $code = <<"EOLATINCODE"; my \$var_with_\xE9_accent = 10; print \"var is \$var_with_\xE9_accent\\n\"; EOLATINCODE $code = decode('latin1', $code); print "CODE is $code\n"; eval $code; if ($@) { print "DIED: $@\n"; }
    You don't seem to need 'use utf8' in the eval'd code in this case, but you seem to need it in the containing script.
Re^3: Bug : eval and accent
by borisz (Canon) on Nov 16, 2007 at 13:04 UTC
    your script must be in utf8, it is latin1 currently. Convert the script to utf8 and retry.
    Boris

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-19 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found