I am trying to learn python and couldn’t figure out how to translate the following perl script to python:
#!/usr/bin/perl -w
use open qw(:std :utf8);
while(<>) {
s/\x{00E4}/ae/;
s/\x{00F6}/oe/;
s/\x{00FC}/ue/;
print;
}
The script just changes unicode umlauts to alternative ascii output. (So the complete output is in ascii.) I would be grateful for any hints. Thanks!
fileinputmodule to loop over standard input or a list of files,translatemethodtranslit.pywould look like this:And you could use it like this:
In case you are using python 3 strings are by default unicode and you dont’ need to encode it if it contains non-ASCII characters or even a non-Latin characters. So the solution will look as follow: