Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode unicode characters to ASCII for Python 2 unicode support #21

Closed

Conversation

Zach10za
Copy link

fixes #1

Problem

When converting cases in Python 2 when the data has a unicode character in it, you will get this UnicodeEncodeError:

UnicodeEncodeError: 'ascii' codec can't encode character u'\uXXXX' in position 4: ordinal not in range(128)

Solution

Try/except converting the input to a string with str. If a UnicodeEncodeError is raised then encode the string to 'ascii' and continue.

@Zach10za Zach10za closed this Feb 28, 2020
@Zach10za Zach10za deleted the zach/encode-unicode-to-ascii branch February 28, 2020 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it work for Unicode characters
1 participant