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

Fixed encoding issue. See #35 #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

faisal-hameed
Copy link

Fixed encoding issue due to non-utf8 characters in commit messages.

@@ -97,7 +97,8 @@ def decodeString(encoding, encodestr):
return encodestr.decode(encoding)
except UnicodeDecodeError as e:
print >> sys.stderr, encodestr, ":", e
return encodestr.decode(encoding, "ignore")
ascii_only = re.sub(r'[^\x00-\x7f]',r' ',encodestr)
return encodestr.decode(ascii_only, "ignore")
Copy link
Owner

Choose a reason for hiding this comment

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

I'm just curious, isn't the whole point of "ignore" here to stop errors being thrown?

Choose a reason for hiding this comment

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

I agree with @charleso,
and the fact that the original code does not work seems to indicate that the exception thrown is not the one you are trying to catch here.
According to the docs the exception to catch is
UnicodeError
instead of
UnicodeDecodeError

bytes.decode(encoding='utf-8', errors='strict')
bytearray.decode(encoding='utf-8', errors='strict')
Return a string decoded from the given bytes. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. The default for errors is 'strict', meaning that encoding errors raise a UnicodeError. Other possible values are 'ignore', 'replace' and any other name registered via codecs.register_error(), see section Error Handlers. For a list of possible encodings, see section Standard Encodings.

Just trying to see if that works...

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.

3 participants