Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

I am trying to do this - converting from wstring works incorrectly! #2642

Closed
lipasite opened this issue Feb 14, 2021 · 0 comments
Closed

I am trying to do this - converting from wstring works incorrectly! #2642

lipasite opened this issue Feb 14, 2021 · 0 comments

Comments

@lipasite
Copy link

I am trying to do this - converting from wstring works incorrectly!
I need add to json array of objects wstring values,
and then convert to plain wchar_t string!

But all I try - didnt work! This is screenshot!

auto jsonProducts = json::array();
while (...) {
  std::wstring productRID_w (ValByName(GoodsQ));
  std::wstring productName_w (ValByName2(GoodsQ));
  // convert to json
  json product = {
	{"productRID", productRID },
	{"productName", productName}
  };
jsonProducts.push_back(product);
}
std::string jStr = jsonProducts.dump();
std::wstring widestr = std::wstring(jStr.begin(), jStr.end());
wchar_t* tempWide = const_cast<wchar_t*>(widestr.c_str());
return tempWide;

So, the wstring L"test" after adding to jon object becomes "Р\xfҐP\a"

What the hell, man?
How to fix it?
Or suggest a normal C ++ library that can work correctly with wstring.
Be so kind....

Originally posted by @lipasite in #2641

Repository owner locked and limited conversation to collaborators Feb 14, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants