Error

C++博客 首页 新随笔 联系 聚合 管理
  217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks

#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
#include <fstream>
int main(int argc, char *argv[])
{
   std::wstring str = L"123,我是谁?我爱钓鱼岛!";
   std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
   std::string narrowStr = conv.to_bytes(str);
   {
      std::ofstream ofs ("c:\\test.txt");
      ofs << narrowStr;
   }
   std::wstring wideStr = conv.from_bytes(narrowStr);
   {
      std::locale::global(std::locale("Chinese-simplified"));
      std::wofstream ofs (L"c:\\testW.txt");
      ofs << wideStr;
   }

posted on 2012-09-12 13:37 Enic 阅读(100) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理