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