You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
754 B

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Sebastian Pipping <>
# Licensed under GPL v3 or later
from __future__ import print_function
def asciify(utf8):
_mapping = (
('ö', 'oe'),
('Ö', 'Oe'),
('ä', 'ae'),
('Ä', 'Ae'),
('ü', 'ue'),
('Ü', 'Ue'),
('ß', 'ss'),
_mapping = dict(((ord(unicode(key, 'utf-8')), value) for key, value in _mapping))
def subst(unichar):
def fix(unichar):
if ord(unichar) > 127:
return unicode('?')
return unichar
return _mapping.get(ord(unichar), fix(unichar))
unichars = utf8.decode('utf-8')
unitext = ''.join(subst(e) for e in unichars)
return unitext.encode('ascii')
if __name__ == '__main__':