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

preserve printable unicode in protoprint #529

Merged
merged 1 commit into from Aug 22, 2022

Conversation

jhump
Copy link
Owner

@jhump jhump commented Aug 22, 2022

There is not enough information in the descriptor to preserve the exact encoding used in the original source. So the strategy it employs is to use unicode.IsPrint to decide if it needs to be encoded. If so, it uses an octal escape for values that fit in 7 bits, short unicode escapes for values that fit in 16 bits, and long unicode escapes for anything else.

Literal values for bytes fields use the more aggressive encoding -- any byte outside the 7-bit ASCII printable range is encoded. But, for string fields, it will now preserve unicode in the output instead of escaping everything.

Fixes #527

@jhump jhump merged commit bccb0aa into master Aug 22, 2022
@jhump jhump deleted the jh/protoprint-preserves-unicode branch August 22, 2022 16:32
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.

protoprint: printable unicode characters >= code point 0080 are not preserved
1 participant