Skip to content

Instantly share code, notes, and snippets.

@alioguzhan
Created November 16, 2013 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alioguzhan/7500801 to your computer and use it in GitHub Desktop.
Save alioguzhan/7500801 to your computer and use it in GitHub Desktop.
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
uname.append(l)
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