json.exception.type_error.316 Extended ASCII with cout #3997
Unanswered
paulpaul9740
asked this question in
Q&A
Replies: 1 comment
-
See https://json.nlohmann.me/home/faq/ and "Parse errors reading non-ASCII characters" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
version 3.10.4
Hello! Im trying to store and print extended ASCII string like this
using json = nlohmann::json; json test; test += json::object_t::value_type{"qwe","абвгдежз"}; try { std::string b = test["qwe"]; std::cout << b << std::endl; } catch (std::exception &e) { std::cout << e.what() << std::endl; return 0; }
It's working fine.
But if trying to print it without implicit conversion to std::string
std::cout << test["qwe"]<< std::endl;
,I've got an exception "[json.exception.type_error.316] invalid UTF-8 byte at index 1: 0xE1"
I find out about utf-8 supporting only, but i don't realize a few moments:
1)Why the first way is working fine?
2) How can I use second way with ignoring of exception? I find out that the function "dump" is calling in operator overloading(I suppose the problem in it), Any chance to pass "json::error_handler_t::ignore" to it? or do smth else?
Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions