Created
November 16, 2013 14:36
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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