Issue 36 in open-vcdiff: Failed to handle utf8 characters in .json file

5 views
Skip to first unread message

open-...@googlecode.com

unread,
Oct 31, 2012, 11:02:45 AM10/31/12
to open-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 36 by sunzhuo...@gmail.com: Failed to handle utf8 characters
in .json file
http://code.google.com/p/open-vcdiff/issues/detail?id=36

What steps will reproduce the problem?
1. create file "test1.js", input "你好", and save it without BOM.
2. create file "test2.js", input "你好么", and save it without BOM, too.
3. use command line: vcdiff encode -json -dictionary test1.js -target
test2.js -delta delta.js

What is the expected output? What do you see instead?
the excpeted output:
["\u00e4\u00bd\u00a0\u00e5\u00a5\u00bd\u00e5\u0090\u0097",]
what I see:
["\ufffff\ufffff\ufffff\ufffff\ufffff\ufffff\ufffff\ufffff\ufffff",]


What version of the product are you using? On what operating system?
version: 0.8.3
OS: Mac OS X 10.7.4

Please provide any additional information below.
The issue is caused by bad "JSONCodeTableWritter::JSONEscape(...)". and
the root cause is using "signed char" as "unsigned char" in line 55. here
is the fragment and fix:
void JSONCodeTableWriter::JSONEscape(const char* data,
size_t size,
string* out) {
for (size_t i = 0; i < size; ++i) {
//const char c = data[i]; // wrong type
const unsigned char c = (const unsigned char)data[i]; // use
unsigned char instead



Reply all
Reply to author
Forward
0 new messages