storesafe/cordova-sqlite-storage

Query result contains wrong key when column name is CJK character

yelusaku opened this issue · 2 comments

Create table sql string: "CREATE TABLE IF NOT EXISTS test_table (id integer primary key, '\u540D\u5B57' text, data_num integer))",
insert data sql string: "INSERT INTO test_table ('\u540D\u5B57', data_num) VALUES ('周杰伦', 100)",
query result: {"data_num":100,"id":1,"ÂêçÂ≠ó":"周杰伦"} ,
the key "名字" should be "u540D\u5B57".

I tried to modified the file SQLitePlugin.m in src/ios directory, line 387:
//columnName = [NSString stringWithFormat:@"%s", sqlite3_column_name(statement, i)];
columnName = [[NSString alloc] initWithBytes:(char *)sqlite3_column_name(statement, i)
length:strlen(sqlite3_column_name(statement, i))
encoding:NSUTF8StringEncoding];
#if !__has_feature(objc_arc)
[columnName autorelease];
#endif,
and it worked.

Thanks @yelusaku. As I said in #642 I will test on other platforms before integrating. It may take me a few weeks due to some existing workload.