Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions xclib/utf8.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ def unutf8(u, opts='strict'):
traceback.print_exc()
return 'illegal-utf8-sequence-' + dec
else:
return u.decode('utf-8', opts)

try:
return u.decode('utf-8', opts)
except AttributeError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be return u instead?

Copy link
Contributor Author

@Failure404 Failure404 Feb 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably yes,
but I am not familiar with the code and I thought there could be cases where the object is not already decoded.
If that's not the case, then return u sounds like the most logical approach :-)


def utf8l(l):
'''Encode a copy of the list, converted to UTF-8'''
return list(map(utf8, l))