Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

strip unicode characters from strings python


def strip_non_ascii(string):
    ''' Returns the string without non ASCII characters'''
    stripped = (c for c in string if 0 < ord(c) < 127)
    return ''.join(stripped)


test = u'éáé123456tgreáé@€'
print test
print strip_non_ascii(test)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #strip #unicode #characters #strings #python
ADD COMMENT
Topic
Name
9+2 =