Make string handling unicode-preserving#25
Open
m7a wants to merge 1 commit intomazenharake:masterfrom
Open
Conversation
Previously, it was impossible to output non-ASCII characters using cecho for multiple reasons: * Strings were processed as flattened lists. This caused encoding information to not be preserved properly. * Data was transmitted as string from the Erlang to the C side causing encoding information not to arrive correctly. * The library linked against libncurses rather than libncursesw and as a result, no “wide character” support was available. This commit fixes this by switching the string handling to be based on iolists and binaries. String values are transferred to the C-side as binaries rather than strings now. Additionally, upon compilation, the C part is linked against `libncursesw` in favor of the previously chosen `libncurses`. The API remains compatible with preceding invocations and still allows strings to be passed to all of the string functions.
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.
Hello,
I tried to get cecho to work with non-ASCII characters but it looked as if they were always mangled. After some digging into the code I came up with a solution for the string-processing functions that keeps UTF-8 data as-is resulting in correct display on my terminal (urxvt).
Feel free to include it into the upstream if it makes sense to you 😄
I think this patch is good, but it could still be incomplete e.g. I did not test with non-ASCII border drawing characters yet. A similar issue might come up there, too, but it could then possibly be resolved in a separate commit?
Thanks in advance
Linux-Fan (@m7a)
Commit Message
Previously, it was impossible to output non-ASCII characters using cecho for multiple reasons:
This commit fixes this by switching the string handling to be based on iolists and binaries. String values are transferred to the C-side as binaries rather than strings now.
Additionally, upon compilation, the C part is linked against
libncurseswin favor of the previously chosenlibncurses.The API remains compatible with preceding invocations and still allows strings to be passed to all of the string functions.