在console中 使用C Runtime 和 STL 显示 Unicode中文
来源:互联网 发布:windows远程控制mac 编辑:程序博客网 时间:2024/06/06 08:40
这篇文章应该是[netsin]的成果,我勤快,记下来。
注:wprintf是C的标准库函数,但wcout不是C++的标准成员,C++中的L”……”是宽字符,却未必是unicode字符,这与编译器实现相关。
本文中的代码执行环境是 windows xp professional 英文版,编译器是 VS2005RTM。
// C
#include
#include
int main( void )
{
setlocale( LC_ALL, "Chinese-simplified" );
//setlocale( LC_ALL, "chs" );
//setlocale( LC_ALL, "ZHI" );
//setlocale( LC_ALL, ".936" );
wprintf( L"中国" );
return 0;
}
// C++
#include
#include
using namespace std;
int main( void )
{
locale loc( "Chinese-simplified" );
//locale loc( "chs" );
//locale loc( "ZHI" );
//locale loc( ".936" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}
说明:别混合使用 setlocale 和 std::locale 。
遗留问题:在中文xp系统下是否也可行,因为netsin似乎说过有问题,等netsin明天来详细说明。
- 在console中 使用C Runtime 和 STL 显示 Unicode中文
- 在console中 使用C Runtime 和 STL 显示 Unicode中文
- 在console中 使用C Runtime 和 STL 显示 Unicode中文
- 在console中 使用C Runtime 和 STL 显示 Unicode中文
- 在console中 使用C Runtime 和 STL 显示 Unicode中文
- C++unicode中文显示
- 在eclipse 的console中正确显示中文
- 在Linux C编程中使用Unicode和UTF-8
- 在Linux C编程中使用Unicode和UTF-8
- 在Linux C编程中使用Unicode和UTF-8
- 在Linux C编程中使用Unicode和UTF-8
- Elang在Windows console下显示中文
- 在 console mode 中使用 C/C++ 编译器
- 侯捷:在 console mode 中使用 C/C++ 编译器
- 在 console mode 中使用 C/C++ 编译器
- 在 console mode 中使用 C/C++ 编译器
- 在 console mode 中使用 C/C++ 编译器
- 在 console mode 中使用 C/C++ 编译器
- WINX的消息分派机制(终结篇)
- MFC的子类化技术
- 右键文件关联
- 【基础】如何建立第一个winx程序
- VC编程经验汇总(三)
- 在console中 使用C Runtime 和 STL 显示 Unicode中文
- boost::pool与内存池技术
- WINX的消息分派机制(续2)
- VC编程经验汇总(二)
- [MSSQL]将用户表 存储过程 变成系统的
- C++内存管理变革(2):最袖珍的垃圾回收器
- Programming C# 4th. Edition 中文/英文版对照阅读体验
- VC编程经验汇总(一)
- 重载new/delete要遵循的规则