The evil C++ -- vsprintf, UNICODE, error output string
来源:互联网 发布:sql转义字符 单引号 编辑:程序博客网 时间:2024/06/16 18:59
Before this time, I always believe building the program with UNICODE or non UNICODE flag only effect the programatic side, and won't effect the system behavior. The problem arose with mixing usage of multi-byte and unicode character set functionalities under the UNICODE base. Such as if the UNICODE is the base setting, then any multi-byte function's call may appear unpredictable behavior. Please take a look at the following example:
// we suppose the UNICODE is defined, but we still need to support the multi-byte stringvoid Log(const char * InFmt, ...){ char buffer[256]; // something is done. vsprintf(buffer, InFmt, valist); wprintf(MULTIBYTE_TO_UNICODE(buffer));}
The output 'buffer' may not process the right string that you want, and the solution is at first convert all the string into Unicode style, and then use the Unicode function to process the string, such as:
// we suppose the UNICODE is defined, but we still need to support the multi-byte stringvoid Log(const char * InFmt, ...){ // we are work under UNICODE try turn all the string value into Unicode style wchar_t buffer[256]; // something is done. // and then use the UNICODE function to process string vswprintf(buffer, MULTIBYTE_TO_UNICODE(InFmt), valist); wprintf(buffer);}
- The evil C++ -- vsprintf, UNICODE, error output string
- the evil cmake -- string concatenation
- the evil VC -- Visual C++ project, macro, output file
- The evil CMake -- Compile bug, missing ')', error line number
- error MSB8011: Failed to register output. Please try enabling Per-user Redirection or register the c
- Output error file to the following location
- vsprintf.c源代码
- linux-vsprintf.c
- vsprintf.c 源码
- vsprintf.c源代码
- 第二章 Unicode简介 sprintf 、vsprintf 、_vsntprintf
- [Android] Unparsed aapt error(s)! Check the console for output
- [Android] Unparsed aapt error(s)! Check the console for output
- 【转】Unparsed aapt error(s)! Check the console for output
- Compile failed; see the compiler error output for details
- Unparsed aapt error(s)! Check the console for output
- Unparsed aapt error(s)! Check the console for output解决方法
- Unparsed aapt error(s)! Check the console for output解决方法
- ireport 变量之间进行计算
- Dojo动态创建TabContainer
- The evil CMake -- Compile bug, missing ')', error line number
- UC故事 2011/11/20 - 2
- qt4 tcp/ip协议4个层次
- The evil C++ -- vsprintf, UNICODE, error output string
- VNC配置整理
- C++中最大值算法
- linux的运行模式:Runlevel详细解析
- 单文档中如何把菜单栏改成中文
- char.varchar.varchar2的区别
- 2.0联系人增、删、改、查
- Linux内核分析 - 网络[十二]:UDP模块 - 收发
- 鼠标滚轮在QQ上面不能使用