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

Review unicode support #1

Open
SevereOverfl0w opened this issue Oct 12, 2016 · 0 comments
Open

Review unicode support #1

SevereOverfl0w opened this issue Oct 12, 2016 · 0 comments

Comments

@SevereOverfl0w
Copy link
Member

Unicode support was added somewhat hastily. I pretty much just shoved a b in front of all the strings, and switched StringIO for BytesIO.

  • I'm not entirely sure that StringIO is even used anymore. The import may be removable
  • For some reason, StringIO can be imported as either from StringIO import StringIO or from io import StringIO, what are their differences? does something similar apply to BytesIO?
  • This code
    # x = x.encode("UTF-8")
    # TODO revisit encodings, this is surely not right. Python
    # (2.x, anyway) conflates bytes and strings, but 3.x does not...
    out.write(str(len(x.encode('utf-8'))).encode('utf-8'))
    the comment probably doesn't need to be there anymore and it should be split up to ensure that it's understood that it's doing two things:
  • Getting the length of the string in bytes
  • Turning that length into a utf-8 encoded string

There's probably more refactoring to look into, but this is what comes to mind.

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

No branches or pull requests

1 participant