Developers’ Weblog

Sponsored by
HostEurope Logo

Developers’ Weblog

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

perl and HTML entities

22.04.2009 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