Chinese character initialize error
What is the issue you have?
//main.cpp encode=utf8
int main(int argc, char ** argv)
{
std::cout << "Hello CMake." << std::endl;
setlocale(LC_ALL, "chs");
try
{
// create object from string literal
auto jsonStr1 = "{\"name\": \"中国\", \"happy\": true, \"pi\": 3.141 }"_json; // **this is error**
auto jsonStr2 = R"(
{
"name": "中国",
"happy": true,
"pi": 3.141
}
)"_json;// **this is error also**
{
json con_json;
con_json["aaa"] = "张三";//**this is ok**
std::cout << con_json.dump() << std::endl;
}
} catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
}
}
#[error info]:
[json.exception.parse_error.101] parse error at line 3, column 14: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"中'
Please describe the steps to reproduce the issue.
1.build ok
2.run error.
3.
Can you provide a small but working code example?
What is the expected behavior?
Normal parse
And what is the actual behavior instead?
con_json["aaa"] = "张三";//this is ok
auto jsonStr1 = "{"name": "中国", "happy": true, "pi": 3.141 }"_json; // this is error
auto jsonStr2 = R"(
{
"name": "中国",
"happy": true,
"pi": 3.141
}
)"_json;// this is error also
Which compiler and operating system are you using?
- Compiler: msvc_vs2019
- Operating system: win10v2004_
Which version of the library did you use?
If you experience a compilation error: can you [compile and run the unit tests]
Chinese character initialize error
What is the issue you have?
#[error info]:
[json.exception.parse_error.101] parse error at line 3, column 14: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"中'
Please describe the steps to reproduce the issue.
1.build ok
2.run error.
3.
Can you provide a small but working code example?
What is the expected behavior?
Normal parse
And what is the actual behavior instead?
con_json["aaa"] = "张三";//this is ok
auto jsonStr1 = "{"name": "中国", "happy": true, "pi": 3.141 }"_json; // this is error
auto jsonStr2 = R"(
{
"name": "中国",
"happy": true,
"pi": 3.141
}
)"_json;// this is error also
Which compiler and operating system are you using?
Which version of the library did you use?
developbranchIf you experience a compilation error: can you [compile and run the unit tests]