I used mppoker/cpp-httplib
bool Request::Login(){ std::string json = "{ \"email\": \"" + std::string(User::GetUsername()) +"\", \"password\": \"" + std::string(User::GetPassword()) +"\" }"; auto res = client->Post("/api/client/auth/login", json, "application/json"); if (res && res->status == 200) { auto j = nlohmann::json::parse(res->body); // perty print int indent = 4; std::string s = j.dump(indent); return true; } else { auto j = nlohmann::json::parse(res->body); std::string err = j["error"]; MessageBox(NULL, err.c_str(), "Error", MB_OK); return false; }}
Example API Response
{"statusCode": 400,"error": "`Email sai định dạng`""path": "/api/client/auth/login","method": "POST"}
The code I provided is returning an error message from an API in json format, but when trying to display the error message in a MessageBox, the utf-8 characters are not being displayed correctly. What can I do to properly display utf-8 encoded characters in a MessageBox in C++?