考虑这个示例程序:
#include <cstdio>
#include <cwchar>
#include <string>
int main()
{
std::string narrowstr = "narrow";
std::wstring widestr = L"wide";
printf("1 %s \n", narrowstr.c_str());
printf("2 %ls \n", widestr.c_str());
wprintf(L"3 %s \n", narrowstr.c_str());
wprintf(L"4 %ls \n", widestr.c_str());
return 0;
}
这个的输出是:
1 narrow
2 wide
我在想:
- 为什么不打印 3 和 4?
- 1 & 3 和 2 & 4 有什么区别?
- 如果
narrowstr
是 UTF8 和widestr
UTF16 有什么区别吗?