in reply to unknown character in between text
If you wanted to replace the offending character with its HTML entity, without using modules, you could maybe do something like this, which should work in many cases, (or use the commented line instead to replace the character with a space):
for (my $x=0;$x<length($string);$x++) { if (ord(substr($string,$x,1))>127) { substr($string,$x,1)='&#'.ord(substr($string,$x,1)).';'; # substr($string,$x,1)=' '; # or use this line instead } }
... or, if you just wanted to know what a character is meant to be, then you could do something like this:
for (my $x=0;$x<length($string);$x++) { print ord(substr($string,$x,1)),"\t",substr($string,$x,1),"\n"; }
Hope that helps, although all the modules and tools mentioned above are useful methods too. (and I'm sure some guru could likely condense the code above into a single line).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: unknown character in between text
by Anonymous Monk on Sep 17, 2011 at 13:00 UTC | |
by DanielSpaniel (Scribe) on Sep 17, 2011 at 13:05 UTC | |
by Anonymous Monk on Sep 17, 2011 at 13:54 UTC | |
by Anonymous Monk on Sep 17, 2011 at 13:56 UTC | |
by DanielSpaniel (Scribe) on Sep 17, 2011 at 14:20 UTC |