Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^5: sring encode problem (hexadecimal)

by JavaFan (Canon)
on Jan 20, 2011 at 09:59 UTC ( [id://883276]=note: print w/replies, xml ) Need Help??


in reply to Re^4: sring encode problem (hexadecimal)
in thread sring encode problem (hexadecimal)

Works for me:
#!/usr/bin/perl use 5.010; use strict; use warnings; use HTML::Entities qw[encode_entities_numeric]; my $string = "\x{20AC}"; my $encoded = encode_entities_numeric $string; say $encoded; __END__ €

Replies are listed 'Best First'.
Re^6: sring encode problem (hexadecimal)
by courierb (Novice) on Jan 20, 2011 at 14:36 UTC
    Hi JavaFan

    Thank you for your code. you are right. now it is work indeed
    however in your code
    line 7 my $string = "\x{20AC}";
    Is "\x{20AC}" equvalent to "€";??


    why do you use my $string = "\x{20AC}"; instead of $string = "€";
    would it be possible to use
    my $string = "€"; ??
    as i would pass value from form to it . these value would be any double byte character.




    Many thanks

      They are equivalent. I prefer to use \x{20AC} (and \x escapes in general) because that's encoding agnostic. If you write $string = "€";, I cannot see whether that's UTF-8, or perhaps ISO-8856-15.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-25 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found