Compile liblouis with 32 bit widechars and add textUtils module to deal with py2/py3 unicode differences#9044
Closed
LeonarddeR wants to merge 15 commits into
Closed
Compile liblouis with 32 bit widechars and add textUtils module to deal with py2/py3 unicode differences#9044LeonarddeR wants to merge 15 commits into
LeonarddeR wants to merge 15 commits into
Conversation
added 13 commits
December 10, 2018 18:44
Collaborator
Author
|
@feerrenrut @michaelDCurran @jcsteh: I requested review from the three of you, because especially with the textUtils approach, I really want to take the right step. Note that I'm still open for feedback or massive changes. I just wanted to deliver something that actually seems to demonstrate the idea behind the module pretty well. |
Collaborator
Author
|
I'm going to close this for now:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Closes #9034
Closes #6695
Summary of the issue:
Liblouis currently uses a 2 byte encoding to process braille. This is pretty annoying when displaying emoji, as they are 32 bit unicode characters. For example, 😉 is usually printed as '\xd83d''\xde09'.
Description of how this pull request fixes the issue:
This pr does the following.
This is where textUtils.ENcodingAwareString comes into view. This new str subclass of unicode in python 2/str in python 3 keeps the decoded and encoded form of a string in one object. Indexing/slicing/length checking is based on the smallest with of the encoding used. For example, utf-16 is two bytes, so every index in the string corresponds with two bytes. Utf-32 uses four bytes for one character, so every index corresponds with four bytes in the string. This basically means that we have strings that behave like python 3 strings on python 2, and strings that behave like python 2 strings on python 3.
Testing performed:
Tested a try build with braille, routing worked well, no unexpected errors in the log so far.
Known issues with pull request:
No unit tests, and we really want them, I'm sure. however, first I want to make sure that we agree about the approach of the textUtils module.
Change log entry: