Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unicode strings #878

Closed
zoncpp opened this issue Dec 15, 2017 · 8 comments
Closed

unicode strings #878

zoncpp opened this issue Dec 15, 2017 · 8 comments
Labels
platform: visual studio related to MSVC solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@zoncpp
Copy link

zoncpp commented Dec 15, 2017

  • How do I work by unicode json strings.

I have unicode strings in my json . some values are unicode .
Now, how do I change the json class (json.hpp) for my project?

My Project is in VS 2015.

@nlohmann
Copy link
Owner

I do not understand the question. The library only supports UTF-8. If you mean this with "Unicode", then everything should be fine. If not, could you please provide example code and the respective error message?

@nlohmann nlohmann added platform: visual studio related to MSVC state: needs more info the author of the issue needs to provide more details labels Dec 15, 2017
@zoncpp
Copy link
Author

zoncpp commented Dec 15, 2017

Setting of my VC Project in Character Set is "Use Unicode Character Set"
Then I have Unicode strings in values of Json String :

auto j3 = json::parse("{ \"name\": \"زهره\", \"LastName\": \"نادری\" }");
	CString ss = j3["name"];

this assigned has error

@nlohmann
Copy link
Owner

The library stores strings as std::string. Maybe assigning it to a CString does not work. What is the exact error message?

@zoncpp
Copy link
Author

zoncpp commented Dec 15, 2017

CString or std::wstring . both has error.
std::wstring ss = j3["name"];
that error is:

json.hpp(1384): error C2100: illegal indirection

@nlohmann
Copy link
Owner

Maybe helpful: https://stackoverflow.com/a/258052/266378

@nlohmann
Copy link
Owner

As I wrote before: the library stores strings as std::string. If you want to convert them to another type like CString or std::wstring, then you need to provide the code for this.

@zoncpp
Copy link
Author

zoncpp commented Dec 15, 2017

Thanks so much for your online response

@nlohmann nlohmann added solution: proposed fix a fix for the issue has been proposed and waits for confirmation and removed state: needs more info the author of the issue needs to provide more details labels Dec 15, 2017
@nlohmann
Copy link
Owner

nlohmann commented Aug 1, 2021

I added an FAQ entry: https://json.nlohmann.me/home/faq/#wide-string-handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: visual studio related to MSVC solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants