是否有格式说明符始终表示带有 _tprintf 的字符字符串? [英] Is there a format specifier that always means char string with _tprintf?

查看:66
本文介绍了是否有格式说明符始终表示带有 _tprintf 的字符字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您使用 TCHAR 支持在 Windows 上构建应用程序时,_tprintf() 中的 %s 表示 char *> 字符串用于 Ansi 构建,wchar_t * 用于 Unicode 构建,而 %S 表示相反.

When you build an app on Windows using TCHAR support, %s in _tprintf() means char * string for Ansi builds and wchar_t * for Unicode builds while %S means the reverse.

但是是否有任何格式说明符总是表示 char * 字符串,无论它是 Ansi 还是 Unicode 版本?由于即使在 Windows 上,UTF-16 也没有真正用于文件或网络,因此无论您将应用程序编译为何种本机字符类型,您仍然需要处理基于字节的字符串.

But are there any format specifiers that always mean char * string no matter if it's an Ansi or Unicode build? Since even on Windows UTF-16 is not really used for files or networking it turns out to still be fairly often that you'll want to deal with byte-based strings regardless of the native character type you compile your app as.

推荐答案

h 修饰符强制 %s%Schar*l 修饰符强制两者都为 wchar_t*,即:%hs, %hS%ls%lS.

The h modifier forces both %s and %S to char*, and the l modifier forces both to wchar_t*, ie: %hs, %hS, %ls, and %lS.

这篇关于是否有格式说明符始终表示带有 _tprintf 的字符字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆