On Sunday 18 September 2016 13:30, Peng Yu wrote: > On Sat, Sep 17, 2016 at 3:20 PM, Martin Schöön <martin.sch...@gmail.com> > wrote: >> Den 2016-09-17 skrev Kouli <d...@kou.li>: >>> Hello, try the Unidecode module - https://pypi.python.org/pypi/Unidecode. > > I don't find a way to make it print oe for ö. Could anybody please > advise what is the correct way to do it?
In general, there is no One Correct Way to translate accented characters into ASCII. It depends on the language, and the word. For instance, in English ö will usually be translated into just o with no accent. We usually write coöperate and zoölogy as cooperate and zoology, or sometimes with a hyphen co-operate, but never cooeperate or zooelogy. But if the word is derived from German, or words that *look* like they might be German, we do sometimes use oe: Roentgen rays (an old term for x-rays) after Wilhelm Röntgen, for instance. But in other languages the rules will be different. How, for example, should one translate an Estonian word containing ö into Turkish, but using ASCII letters only? I have no idea. But in both languages, and unlike German, ö is *not* considered an o-with-an-accent, but a distinct letter of the alphabet. https://en.wikipedia.org/wiki/Diaeresis_%28diacritic%29 As far as Python goes, if all you want to do is replace ö with oe and Ö into OE (or perhaps you should use Œ and œ?) then you can use str.replace or string.translate: mystring.replace("Ö", "OE").replace("ö", "oe") -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list