JSon response is UTF-8 and it must be converted to wchar_t right away
This commit is contained in:
parent
21476e0a5d
commit
402f90b5df
3 changed files with 8 additions and 1 deletions
|
@ -105,6 +105,12 @@ std::string HttpReader::GetPage (const std::string& parAddress) const {
|
|||
return localString;
|
||||
}
|
||||
|
||||
///-----------------------------------------------------------------------------
|
||||
///-----------------------------------------------------------------------------
|
||||
std::wstring HttpReader::GetPageW (const std::string& parAddress) const {
|
||||
return cconv::MultibyteToWide(this->GetPage(parAddress));
|
||||
}
|
||||
|
||||
///-----------------------------------------------------------------------------
|
||||
///-----------------------------------------------------------------------------
|
||||
std::string HttpReader::UrlEncode (const wchar_t* parWord) {
|
||||
|
|
|
@ -7,6 +7,7 @@ public:
|
|||
~HttpReader ( void ) noexcept;
|
||||
|
||||
std::string GetPage ( const std::string& parAddress ) const;
|
||||
std::wstring GetPageW ( const std::string& parAddress ) const;
|
||||
std::string UrlEncode ( const wchar_t* parWord ) __attribute__((pure));
|
||||
std::string UrlEncode ( const std::wstring& parWord ) __attribute__((pure));
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace {
|
|||
oss << "http://api.wordreference.com/" << ApiVersion << "/"
|
||||
<< parKey << "/json/" << parFrom << parTo << "/" << parHttp.UrlEncode(parWord);
|
||||
|
||||
std::string jsonResponse(parHttp.GetPage(oss.str()));
|
||||
std::wstring jsonResponse(parHttp.GetPageW(oss.str()));
|
||||
return libjson::parse(libjson::to_json_string(jsonResponse));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue