Could anyone please let me know how to convert protobuf ByteString to String in java?
In my case, I am getting the ByteString value as "\376\024\367". Is there a way to get the same as String from ByteString? I meant when I print the string value in console using System.out.println(), I should get \376\024\367.
Many thanks.
Normally, you'd convert a ByteString to a String using ByteString#toString(Charset)
. This method lets you specify what charset the text is encoded in. If it's UTF-8, you can also use the method toStringUtf8()
as a shortcut.
From your question, though, it sounds like you actually want to produce the escaped format using C-style three-digit octal escapes. AFAIK there's no public function to do this, but you can see the code here. You could copy that code into your own project and use it.