3,882
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <codecvt>
using namespace std;
int main(void)
{
wstring_convert< codecvt_utf8<wchar_t> > conv;
string s = "我是谁?\n是宽字符串";
wstring ss = conv.from_bytes(s); //转换为宽字符串
cout << ss.find(L"\n") << endl;
wstring ws = L"我是谁?\n是宽字符串"; //直接用宽字符串
cout << ws.find(L"\n") << endl;
return 0;
}