Я студент и разрабатываю ПК-клиент с помощью cpp. Я не знаю, как быть с тем, какой Rapidjson с кодировкой Unicode. Я всегда получаю грязный код. Я шутник о cpp, как я могу получить правильный результат? буду очень признателен!
Просто покажите пример:
class Test {
// I have got the string of json
// eg: { "name" : "小明" }
public : void test(const std::string& data) {
rapidjson::Document json;
json.Parse<0>(data.c_str());
// there are a method GetString() , return a string
// The name value are another Chinese characters(I guess which because of its encoding).
// I want to get a wstring which value is "小明"(Not a messy code). How can i do ?
std::string name = json["name"].GetString();
}
};
// I had used this method
// But still got a messy code
str::UnicodeToAnsi();
std::string
вstd::wstring
. Это не относится к библиотекам json. - person Barmak Shemirani   schedule 26.02.2016UTF-8
и как оно представлено, тогда, вероятно, вам вообще не нужно рассматриватьwstring
. - person Mine   schedule 26.02.2016Unicode
отличается отencoding
.Unicode
можно закодировать вUTF-8
,UTF-16
или другие. - person Mine   schedule 29.02.2016