Created
February 1, 2018 19:54
-
-
Save xfxyjwf/98ae915d3a076c46586f4af7435e1f46 to your computer and use it in GitHub Desktop.
protobuf Java example with 4-bytes UTF-8 characters.
This file contains 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
import xiaofeng.A.Foo; | |
public class A { | |
public static void main(String[] argv) throws Exception { | |
Foo foo = Foo.newBuilder() | |
.setValue("\uD852\uDF62\uD83D\uDE00") | |
.build(); | |
byte[] data = foo.toByteArray(); | |
for (byte b : data) { | |
System.out.println(String.format("\\x%02X", b)); | |
} | |
} | |
} |
This file contains 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
syntax = "proto2"; | |
package xiaofeng; | |
message Foo { | |
optional string value = 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment