Skip to content

Instantly share code, notes, and snippets.

Created November 16, 2013 14:36
What would you like to do?
Takes a string as param, and convert all turkish (non-ascii) chars to ascii.
def get_ascii_name(name):
""" returns a non-ascii -turkish- string to ascii one """
name = name.lower()
map = {u"ı": "i",
u"ğ": "g",
u"ç": "c",
u"ü": "u",
u"ö": "o",
u"ş": "s"}
uname = []
for l in list(name):
for k, v in map.iteritems():
if l == k:
l = v
return ''.join(uname)
## example usage and output
print get_ascii_name("tasarım")
## output: "tasarim"
print get_ascii_name("üşğçı")
## output: "usgci"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment