You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a feature request. I wondered if this is possible. The JSON format is UTF-8. C++11 added char16_t and char32_t for unicode characters, and lately C++20 added char8_t.
Since JSON is specified as UTF-8, this library should at least support char8_t. This add more safety since we can validate and check the character encoding at compile time, prohibiting sending strings to functions that expects another encoding.
What is the issue you have?
Right now, trying to use char8_t with std::u8string in a basic_json result in error.
Please describe the steps to reproduce the issue.
using u8json = basic_json<std::map, std::vector, std::u8string>;
u8json value = {};
This discussion was converted from issue #2337 on August 03, 2020 13:51.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is a feature request. I wondered if this is possible. The JSON format is UTF-8. C++11 added
char16_t
andchar32_t
for unicode characters, and lately C++20 addedchar8_t
.Since JSON is specified as UTF-8, this library should at least support
char8_t
. This add more safety since we can validate and check the character encoding at compile time, prohibiting sending strings to functions that expects another encoding.What is the issue you have?
Right now, trying to use
char8_t
withstd::u8string
in abasic_json
result in error.Please describe the steps to reproduce the issue.
using u8json = basic_json<std::map, std::vector, std::u8string>; u8json value = {};
Compiler explorer link
What is the expected behavior?
The
u8json
alias should work, and conversions tostd::u8string
andstd::u8string_view
should work instead ofstd::string
using this alias.And what is the actual behavior instead?
A compilation error.
Which compiler and operating system are you using?
Which version of the library did you use?
develop
branchIf you experience a compilation error: can you compile and run the unit tests?
Beta Was this translation helpful? Give feedback.
All reactions