Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: sring encode problem (hexadecimal)

by happy.barney (Friar)
on Jan 19, 2011 at 10:56 UTC ( [id://883088]=note: print w/replies, xml ) Need Help??


in reply to sring encode problem (hexadecimal)

search HTML::Entities docs, it looks to me that you are searching for this method:

encode_entities_numeric( $string, $unsafe_chars )

Replies are listed 'Best First'.
Re^2: sring encode problem (hexadecimal)
by courierb (Novice) on Jan 19, 2011 at 11:38 UTC
    Hi happy.barney Thanks for the reply. Actaully i have test it in that way
    but i am unluck to be returned an error
    i cant figure out what happened
    according to the doc i need to use
    encode_entities( $string, $unsafe_chars )


    #!/usr/bin/perl use HTML::Entities; $string="€"; $encoded = encode_entities_numeric($string, '<>&"'); print $encoded;

    The error was read as :
    Undefined subroutine &main::encode_entities_numeric called at 2.cgi line 5.
    i was losted. i did the test in winxp.




    Cheers


      From the documentation of HTML::Entities:
      encode_entities_numeric( $string ) encode_entities_numeric( $string, $unsafe_chars ) This routine works just like encode_entities, except that t +he replacement entities are always "&#xhexnum;" and never "&en +tname;". For example, "encode_entities("r\xF4le")" returns "r&ocirc; +le", but "encode_entities_numeric("r\xF4le")" returns "r&#xF4;le". This routine is not exported by default. But you can alway +s export it with "use HTML::Entities qw(encode_entities_numeric);" o +r even "use HTML::Entities qw(:DEFAULT encode_entities_numeric);"
        well. i am not so understand the doc as English is not my native language.
        here is my code to test it again and it works .
        It do produce string "€" start from "&#x" while it has 5 digits which is not 7 byte string .
        #use HTML::Entities; use HTML::Entities"encode_entities_numeric"; $string="€"; # ("&#x20AC;" expected out put result after encoding) $encoded = encode_entities_numeric($string); print $encoded;





        while when i test it in this way
        #use HTML::Entities; use utf8 ; ########### use HTML::Entities"encode_entities_numeric"; $string="€"; # ("&#x20AC;" expected out put result after encoding) $encoded = encode_entities_numeric($string); print $encoded;
        it print out character "€" itself as if there is no encoding happened.
        what should i do??
        Cheers


        JavaFan i really appreciate y your assitance.
        however i still cant get it work

        could you give me a sample code to prove it ?
        as i have tested it however i got error as i said above.


        cheers



Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2025-07-12 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.