Skip to content

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