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.