Developers’ Weblog

Sponsored by
HostEurope Logo

Developers’ Weblog

⚠ This page contains old, outdated, obsolete, … historic or WIP content! No warranties e.g. for correctness!

All 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

perl and HTML entities

2009-04-22 by tg@
Tags: snippet

I don’t even know perl(1), I just can RTFM…

tg@bleu:~ $ echo 'xyzz�€y' | perl -C -pe \
    's/([\x{7f}-\x{ffff}])/"&#".unpack("U",$1).";"/eg'
xyzz�€y
tg@bleu:~ $ echo 'xyzz�€y' | perl -C -pe \
    's/([\x{7f}-\x{ffff}])/sprintf "&#x%X;",unpack("U",$1)/eg'
xyzz�€y

Just hacked it for Natureshadow.

MirOS Logo