Skip to content

Unicode error in python2.7 #72

@bajibabu

Description

@bajibabu

Hi,
I got the following error while running char_rnn_classification_tutorial.py

print(unicodeToAscii('Ślusàrski'))
 File "src/char_rnn.py", line 17, in unicodeToAscii
   c for c in unicodedata.normalize('NFD', s)
TypeError: normalize() argument 2 must be unicode, not str

To circumvent the error I changed the code:

def unicodeToAscii(s):
    try:
        s = unicode(s, 'utf-8')
    except NameError:
        pass
    s = unicodedata.normalize('NFD', s)
    s = s.encode('ascii', 'ignore')
    s = s.decode('utf-8')
    return str(s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions