Skip to content

Unicode issue: Not able to serialize properly some character like "式,进" #756

Closed
@afrozm

Description

@afrozm

When I build a json object containing UTF8 encoded value of string "式,进"
serialize this json object to string
parse the string again into another json object and read the value
Result: string is lost
here is sample pseudo code

Json::Value json;
json["abc"] = UnicodeToUTF8(L"式,进"); // wrapper over MultiByteToWideChar API
// serialize json to string
std::string jsonString = json.toStyledString();
// now parse again
Json::Value json2 = parse(jsonString); // parse using Json::CharReader
std::wstring unicodeString = UTF8ToUnicode(json2["abc"]); // wrapper over MultiByteToWideChar API
assert(unicodeString == L"式,进"); // fails

I checked UnicodeToUTF8 and UTF8ToUnicode works fine.
The only problem I see in toStyledString() API which make character encoding weird in output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions