Status: New
Owner: [email protected]
Labels: Type-Defect Priority-Medium

New issue 414 by [email protected]: Unexpected behavior of ByteString.toString(charsetName) and ByteString.copyFrom(text, charsetName)
http://code.google.com/p/protobuf/issues/detail?id=414

What steps will reproduce the problem?
byte[] b = new byte[256];
for (int i = 0; i < b.length; i++) {
    b[i] = (byte) i;
}
ByteString bs = ByteString.copyFrom(b);
String sascii = bs.toString("US-ASCII");
String sutf8  = bs.toStringUtf8();
String skoi8  = bs.toString("KOI8-R");
ByteString bsascii = ByteString.copyFrom(sascii, "US-ASCII");
ByteString bsutf8  = ByteString.copyFromUtf8(sutf8);
ByteString bskoi8  = ByteString.copyFrom(skoi8, "KOI8-R");
System.out.print(bs.equals(bsascii) + ", ");
System.out.print(bs.equals(bsutf8) + ", ");
System.out.println(bs.equals(bskoi8));

What is the expected output? What do you see instead?
Output: false, false, true
Expected: true, true, true
It's expected that the bytes that are not supported by chosen charset will be escaped or will be thrown an exception.

What version of the product are you using? On what operating system?
2.4.1

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

Reply via email to