Skip to content

Instantly share code, notes, and snippets.

@xfxyjwf
xfxyjwf / A.java
Created February 1, 2018 19:54
protobuf Java example with 4-bytes UTF-8 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));