Comment #1 on issue 362 by and...@scarabresearch.com: Java: TextFormat can't merge from UTF-8 string
http://code.google.com/p/protobuf/issues/detail?id=362

Sorry that's not the workaround, it's this one:

TextFormat.merge(escapeText(protoStr), b);
...
static private String escapeText(String inStr) {
    ByteString input = ByteString.copyFromUtf8(inStr);
    StringBuilder builder = new StringBuilder(input.size());
    for (int i = 0; i < input.size(); i++) {
        byte b = input.byteAt(i);
        if (b >= 0x0) {
            builder.append((char) b);
        } else {
            builder.append('\\');
            builder.append((char) ('0' + ((b >>> 6) & 3)));
            builder.append((char) ('0' + ((b >>> 3) & 7)));
            builder.append((char) ('0' + (b & 7)));
        }
    }
    return builder.toString();
}


--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to