win32 console unicode _tmain _TCHAR
来源:互联网 发布:工程设计费计算器软件 编辑:程序博客网 时间:2024/06/07 06:57
参考:
http://stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c
http://msdn.microsoft.com/en-US/library/fzc2cy7w(v=VS.80).aspx
在win32 console程序开发中,
Visual C++扩展了标准C++的main函数,定义了wmain入口,新增了wchar_t关键字,以支持Unicode(UTF-16)字符。
(相应的,原有的ASCII字符串的函数有对应的_wxxx, _txxx系列函数)
同时,定义了_tmain用于灵活的在wmain和main之间转换,
定义了_TCHAR用于灵活的在wchar_t和char之间转换。
当定义了_UNICODE时,使用wmain和wchar_t,否则使用main和char。
在visual studio 2010中,开启和关闭_UNICODE的方法如下:
进入项目Properties,
在左侧树形菜单中,选择Configuration Properties->General
在右侧Project Defaults下有Character Set选项,设为Not Set或Unicode。
在Unicode中, ASCII字符的表示方法是在ASCII前加一个'\0'字节,
这样,在X86体系中,由于采用小端表示法,如果使用cout输出Unicode字符,只会输出第一个ASCII字符。
即:
wchar_t *wchr = L"abc";cout<<(char*)wchr<<endl;wcout<<wchr<<endl;会输出:
aabc
- win32 console unicode _tmain _TCHAR
- int _tmain(int argc, _TCHAR* argv[])
- main()和_tmain(int argc, _TCHAR* argv[])
- stdafx.h和int _tmain(int argc, _TCHAR* argv[])
- c/c++ int _tmain(int argc, _TCHAR* argv[])
- _tmain(int argc, _TCHAR* ARGV[])下命令行参数用法
- c/c++ int _tmain(int argc, _TCHAR* argv[])
- c/c++ int _tmain(int argc, _TCHAR* argv[])
- c/c++ int _tmain(int argc, _TCHAR* argv[])
- c/c++ int _tmain(int argc, _TCHAR* argv[])
- c/c++ int _tmain(int argc, _TCHAR* argv[])
- c/c++ int _tmain(int argc, _TCHAR* argv[])
- win32 console
- visual c++ 2008 int _tmain(int argc, _TCHAR* argv[]) 的用法
- int main(int argc, char* argv[])和int _tmain(int argc, _TCHAR* argv[])区别
- _tmain的_TCHAR*argv只读取到每个参数第一个字母的问题
- Win32 Application & Win32 Console Application
- _tmain
- openstack计算节点的安装(虚拟机先建立桥接)
- Delphi自动编译-批处理
- 了解iPhone OS
- 虚拟内存管理
- zlib的安装与使用
- win32 console unicode _tmain _TCHAR
- ssh-keygen的使用方法
- VC中两个井号的妙用
- qt 串口编程
- hibernate三种状态
- ObjectInputStream和ObjectOutputStream读取写入边界判定
- 最简单的画线功能
- 宏定义中的#、##含义
- VC编程CString用法大全