char16_t 打印
最近,由于这些平台之间的 wchar_t
大小差异,我在将 Windows 应用程序移植到 Linux 时遇到了问题。我尝试使用编译器开关,但打印这些字符时出现问题(我推测 GCC wcout
认为所有 wchar_t
都是 32 位)。
所以,我的问题是:有没有一种好的方法来 (w)cout
char16_t
?我问是因为它不起作用,我被迫将其转换为 wchar_t
:
cout << (wchar_t) c;
这看起来不是一个大问题,但它让我烦恼。
Recently I had a problem with porting a Windows application to Linux because of the wchar_t
size difference between these platforms. I tried to use compiler switches, but there were problems with printing those characters (I presume that GCC wcout
thinks that all wchar_t
are 32bit).
So, my question: is there a nice way to (w)cout
char16_t
? I ask because it doesn't work, I'm forced to cast it to wchar_t
:
cout << (wchar_t) c;
It doesn't seem like a big problem, but it bugs me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下:
Give this a try: