小编uoa*_*nci的帖子

为什么字符变得无用?libcurl c++ Utf-8编码的html;

首先,抱歉我的英语不好。\n我已经完成了研究,但没有任何相关答案来解决我的问题。\n我已经理解并了解了 CodePages Utf 8 以及有关 c 或 c++ 中的其他内容,\nand还知道字符串可以保存 utf8。\n我的开发机器 winxp english,控制台代码页设置为 1254(Windows 土耳其语),我可以使用土耳其语扩展字符 (\xc4\xb0\xc4\xb1\xc4\x9f\xc5\x9f\xc3 \xa7\xc3\xbc\xc3\xb6) 在 std::string 中,计算它们并将它们发送到 mysqlpp api 以写入数据库。没有问题。但是当我想使用curl 获取一些html 并将其写入std::string 时,我的问题就开始了。

\n\n
#include <iostream>\n#include <windows.h>\n#include <wincon.h>\n#include <curl.h>\n#include <string>\nint main()\n{\n   SetConsoleCP(1254);\n   SetConsoleOutputCP(1254);\n   std::string s;\n   std::cin>>s;\n   std::cout<<s<<std::endl;\n   return 0;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

当我运行这些并输入 \xc4\x9f\xc5\x9f\xc3\xa7\xc3\xb6\xc3\xbc\xc4\xb0\xc4\xb1 时,输出是相同的 \xc4\x9f\xc5\x9f\xc3\ xa7\xc3\xb6\xc3\xbc\xc4\xb0\xc4\xb1;

\n\n
#include <iostream>\n#include <windows.h>\n#include <wincon.h>\n#include <curl.h>\n#include <string.h>\n\nsize_t writer(char *data, size_t size, size_t nmemb, std::string *buffer);\n{\n   int res;\n   if(buffer!=NULL)\n   {\n      buffer->append(data,size*nmemb);\n      res=size*nmemb;\n   }\n   return res;\n}\nint main()\n{\n   SetConsoleOutputCP(1254);\n   std::string html;\n   CURL *curl;\n   CURLcode result;\n   curl=curl_easy_init();\n …
Run Code Online (Sandbox Code Playgroud)

c++ string utf-8 libcurl codepages

5
推荐指数
1
解决办法
1781
查看次数

标签 统计

c++ ×1

codepages ×1

libcurl ×1

string ×1

utf-8 ×1