Make string handling unicode-preserving #25
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
libncursesw
in 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.