shaikat3 / open-vcdiff

Automatically exported from code.google.com/p/open-vcdiff
Apache License 2.0
0 stars 0 forks source link

Failed to handle utf8 characters in .json file #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by sunzhuo...@gmail.com on 31 Oct 2012 at 3:02

GoogleCodeExporter commented 9 years ago
Resolved in open-vcdiff version 0.8.4.

Original comment by openvcd...@gmail.com on 14 May 2014 at 11:21