std::string strxx = unicode_2_utf8(L"中文utf8转8进制");
CString strOct;
for (int i = 0; i < strxx.length(); i++)
{
int b1 = strxx.at(i);
if (b1 < 0)
{
b1 = 256 + b1;
strOct.AppendFormat(_T("\\%d%d%d"), (b1 / 64) % 8, (b1 / 8) % 8, b1 % 8);
}
else
{
strOct.AppendFormat(_T("%c"), b1);
}
}
std::string unicode_2_utf8(const wchar_t* str)
{
std::string result;
if (str!= NULL && wcslen(str) > 0)
{
CW2A input(str, CP_UTF8);
result= input;
}
return result;
}