MJPA/SimpleJSON

Encoding Issue for ñ.

gddc opened this issue · 2 comments

gddc commented

I seem to get incorrect encoding for accented characters like ñ. I believe the correct encoding for this character should be \u00F1 but it is being encoded as \uFFF1. Later, when the JSON is loaded by another language the ñ does not display correctly.

MJPA commented

Can you provide some sample code where this isn't working?

I've added a simple test case for this locally with the following code which successfully passes:

// Test case for issue #29.
test_output = wstring(L"| Testing encoding ñ being \\u00F1") + wstring(DESC_LENGTH - 31, L' ') + wstring(L" | ");
JSONValue *n_value = new JSONValue(L"ñ");
wstring n_json = n_value->Stringify();
delete n_value;
if (n_json == L"\"\\u00F1\"")
{
    test_output += wstring(L"passed |\r\n");
}
else
{
    test_output += wstring(L"failed |\r\n");
}
print_out(test_output.c_str());
gddc commented

Turns out there may have been a sign problem in another part of our code - the values were being retrieved in a narrow string and converted to a wide string before being passed to JSONValue, which appears to be the root of the problem. Many apologies for the inconvenience.