You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bytes are just small integer numbers, why would you assume that an array of them is a String? In UTF-8 even, why not ASCII?
I could understand if this were an array of characters.
Am I missing something?
@sheepdreamofandroids you are correct, bytes are just small numbers. In case when you communicate over Json, there is no such type as byte, so byte array will be transferred as an array of integers. So normally if you need to transfer byteArray via Json you'd convert it to string, most commonly using base64. In this particular example, I thought using utf-8 is ok, because these bytes are from proto's byteString which I thought already is using utf-8. internally, but I might be totally wrong, and it may need other decoder.
I see, you simply want a more compact encoding of the bytes.
In that case I think that base64 is much safer than a straightforward conversion to text because you avoid all kinds of transformations based on encodings.
On the other hand, if that kind of efficiency is important to you, why not use protobuf or another binary encoding on the client side as well? Nobody forces you to use JSON.
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 freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
2 participants
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.
Currently bytes are returned as an array of bytes, which gets transferred as an array of numbers in Json.

This pr changes so the input and the output for Bytes is expected to be utf-8 encoded string