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
I have a script that makes grpc calls, that return text that's potentially in a different language. In the code, I print out the list of objects who have the attribute transcript, that is the unicode with the text. However, if the text is in fact a double-byte character, it's printed out as escape sequences. Printing out the transcript attribute directly correctly prints out the desired character.
I suspect this is because the str of the protoc-generated response objects are str objects instead of unicode objects. Given that in python3, all string objects default to unicode objects, it might be prudent for the string representations of grpc-generated objects also be unicode objects.
The text was updated successfully, but these errors were encountered:
I'm pretty sure that's working as intended: by default we print all non-ascii characters in escaped sequence. To print non-ascii character without escaping, you can use the text_format utility:
fromgoogle.protobufimporttext_format# The default behavior.printtext_format.MessageToString(msg)
# The behavior you want.printtext_format.MessageToString(msg, as_utf8=True)
Wouldn't it be better if it was unicode, though? Wouldn't that be more consistent with python3, which defaults to unicode? As well as being more friendly to non-english users?u
I have a script that makes grpc calls, that return text that's potentially in a different language. In the code, I print out the list of objects who have the attribute transcript, that is the unicode with the text. However, if the text is in fact a double-byte character, it's printed out as escape sequences. Printing out the transcript attribute directly correctly prints out the desired character.
I suspect this is because the str of the protoc-generated response objects are str objects instead of unicode objects. Given that in python3, all string objects default to unicode objects, it might be prudent for the string representations of grpc-generated objects also be unicode objects.
The text was updated successfully, but these errors were encountered: