Newsgroups: gmane.linux.debian.user Date: Sat, 20 Aug 2005 00:36:14 +0200
> Is there any tools that can convert European characters to plain > 7bit-Ascii?
Or, if you'd like to specify the special characters' hex codes (in case you have problems entering them directly…), you could write instead
#!/usr/bin/perl %mapping = ( 'e4' => 'ae', 'f6' => 'oe', 'fc' => 'ue', 'df' => 'ss', # ... ); $set = join '', map "\\x$_", keys %mapping; while (<>) { s/([$set])/$mapping{sprintf "%x", ord $1}/ge; print; }
Almut Behrens
P.S. Normally, you'd use iconv for encoding conversions. However, "iconv -f 8859_1 -t ASCII isolatin1-file" doesn't work, because ASCII can only represent a subset of characters present in 8859_1 — which makes iconv complain…
> P.S. Normally, you'd use iconv for encoding conversions. However, > "iconv -f 8859_1 -t ASCII isolatin1-file" doesn't work, because ASCII > can only represent a subset of characters present in 8859_1 -- which > makes iconv complain...
recode is better, using the -f option:
ay:~> latin1 | recode -f latin1..ascii 20 !"#$%&'()*+,-./0123456789:;<=>? 40 @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ 60 `abcdefghijklmnopqrstuvwxyz{|}~ A0 !clbSS"(c)a<<not-(R)^2^3'uP.,^1o>>1/41/23/4? C0 `A"AAAEC`E`ID~N`O"OxO`U E0 `a"aaaec`e`id~n`o"o:o`u ay:~> latin1 | recode -f latin1..text 20 !"#$%&'()*+,-./0123456789:;<=>? 40 @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ 60 `abcdefghijklmnopqrstuvwxyz{|}~ A0 ``'' C0 A`A^A"C,E`E'E^E"I^I"O`O^O"U`U^U" E0 a`a^a"c,e`e'e^e"i^i"o`o^o"u`u^u"
Vincent Lefevre