Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Convert accented chars to html escape codes

by kingman (Scribe)
on Jul 28, 2001 at 00:34 UTC ( [id://100448]=CUFP: print w/replies, xml ) Need Help??

This script converts accented characters (high-ordered ascii) to the corresponding HTML escape code. Useful for putting non-english text on a webpage. Populate @ascii_codes with the appropriate code for the characters you wish to convert.
#!/usr/bin/perl @ascii_codes = (153,154,169,171,187..214,224..254); @funny_chars = split("", pack("C*", @ascii_codes)); @input = <>; foreach $line (@input) { for ($x=0; $x<=$#ascii_codes; $x++) { $line =~ s/$funny_chars[$x]/&#$ascii_codes[$x]/g; } print $line; }

Replies are listed 'Best First'.
Re: Convert accented chars to html escape codes
by merlyn (Sage) on Jul 28, 2001 at 10:02 UTC
      Thank you merlyn, I was successful on encoding "Hauptstraße" with HTML::Entities, but not with the node starter code snippet. It saved my life.

      --
      tune

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found