65,187
社区成员




#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string s = "你好CSDN,我的";
string t;
for(int i=0; i<s.length(); i++)
{
if(s[i]<255 && s[i]>0)//扩充的ASCII字符范围为0-255,如是,处理一个字节
{
t.append(s.substr(i,1));
t.append("/");
}
else//<0,>255的是汉字,处理两个字节
{
t.append(s.substr(i,2));
t.append("/");
++i;
}
}
cout << t << endl;//输出符合要求
return 0;
}
int MultiByteToWideChar(
UINT CodePage,
DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte,
LPWSTR lpWideCharStr,
int cchWideChar
);
void main()
{
wstring a = L"Hello您好CSDN";
wstring r;
r = a[0];
for (int i = 1; i < a.length(); ++i)
{
r += L"/";
r += a[i];
}
wcout<<r;
}