GlowPod / protobuf-java-format

Automatically exported from code.google.com/p/protobuf-java-format
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Unescape of Umlaute (öäü) in JsonFormat failed #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Problem:
JsonFormat Line ~1281:

case 'u':
// UTF8 escape
code = 
(16 * 3 * digitValue(input.charAt(i+1))) +
(16 * 2 * digitValue(input.charAt(i+2))) +
(16 * digitValue(input.charAt(i+3))) +
digitValue(input.charAt(i+4));
i = i+4;
result[pos++] = (byte) code;
break;

Correct (not multiplied but by the Power of 16):
case 'u':
// UTF8 escape
code = 
(16 * 16 * 16 * digitValue(input.charAt(i+1))) +
(16 * 16 * digitValue(input.charAt(i+2))) +
(16 * digitValue(input.charAt(i+3))) +
digitValue(input.charAt(i+4));
i = i+4;
result[pos++] = (byte) code;
break;

I attached a version with handels the Umlaute correct.

What steps will reproduce the problem?
1. Build a Message containing a String with Umlaute (äöüÄÖÜäàéè)
2. JsonFormat.print(req.build(), sb);
3. JsonFormat.merge(sb,resp);

What is the expected output? What do you see instead?
The String in the resp Message isn't correct.

I hope this helps to improve this usefull Util.

Original issue reported on code.google.com by helios...@gmail.com on 23 Apr 2011 at 5:23

Attachments:

GoogleCodeExporter commented 8 years ago
This should be fixed by patch to issue 11.

Original comment by philippe...@gmail.com on 26 Apr 2011 at 5:19