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

Non-ASCII characters not converted properly in http_response.extract_utf8_string in MSVC 2019 #1756

Open
jdx-john opened this issue May 16, 2023 · 0 comments

Comments

@jdx-john
Copy link

jdx-john commented May 16, 2023

My server is returning the following as shown in PostMan:

image

{
  "status": "FEL: Det valda objektet för händelsen"
}

In C++ VS2019, reading as a wstring is perfect but if I call response.extract_utf8_string() the JSON has messed up characters, in exactly the same way if I use utility::conversions:

	std::string status = "unknown";
	if (json.has_string_field(L"status"))
	{
		auto tmp = json[L"status"].as_string();
		status = utility::conversions::to_utf8string(tmp);
	}

tmp: L"FEL: Det valda objektet för händelsen"
status: "FEL: Det valda objektet för händelsen"

I need to use this value in a std::exception which only takes std::string what is the correct way to convert and why isn't utf8 working in the first place, when that's how the content is being encoded in the response?

@jdx-john jdx-john changed the title Non-ASCII characters not converted properly in http_response.extract_utf8_string Non-ASCII characters not converted properly in http_response.extract_utf8_string in MSVC 2019 May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant