From e9b24028d32d7d232ae6b170d7f78ffd2d0185fb Mon Sep 17 00:00:00 2001 From: Troels Dalsgaard Hoffmeyer Date: Mon, 14 Sep 2020 16:46:27 +0200 Subject: [PATCH] u8 literal returns a char8_t in C++20 We now use reintepret_cast to cast char8_t's to a const char*, this can be done because char8_t's have the same size and alignment --- src/test_lib_json/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index aeb8a26..f477d27 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -1817,7 +1817,7 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, StaticString) { JSONTEST_FIXTURE_LOCAL(ValueTest, WideString) { // https://github.com/open-source-parsers/jsoncpp/issues/756 - const std::string uni = u8"\u5f0f\uff0c\u8fdb"; // "式,进" + const std::string uni = reinterpret_cast(u8"\u5f0f\uff0c\u8fdb"); // "式,进" std::string styled; { Json::Value v; @@ -2905,8 +2905,8 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, strictModeParseNumber) { } JSONTEST_FIXTURE_LOCAL(ReaderTest, parseChineseWithOneError) { - checkParse(R"({ "pr)" - u8"\u4f50\u85e4" // 佐藤 + checkParse(R"({ "pr)" + + std::string(reinterpret_cast(u8"\u4f50\u85e4")) + // 佐藤 R"(erty" :: "value" })", {{18, 19, "Syntax error: value, object or array expected."}}, "* Line 1, Column 19\n Syntax error: value, object or array " @@ -3008,7 +3008,7 @@ JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseString) { bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs); JSONTEST_ASSERT(ok); JSONTEST_ASSERT(errs.empty()); - JSONTEST_ASSERT_EQUAL(u8"\u8A2a", root[0].asString()); // "訪" + JSONTEST_ASSERT_EQUAL((const char*)u8"\u8A2a", root[0].asString()); // "訪" } { char const doc[] = R"([ "\uD801" ])";