C++本地化小结
来源:互联网 发布:amd cpu优化 编辑:程序博客网 时间:2024/05/16 14:33
MinGW对c++的std::locale支持不佳,在MinGW程序下使用本地化功能要直接用c版本,setlocale(LC_ALL, "");
这样wchar_t就可以一次性读2个字节的数据了,否则wchar_t只可以一次性读一个字节。但是输出的时候,不能用wcout,只能用wprintf输出。
例如wprintf(L"%lc ",temp);
写一个小程序,统计文本中所有汉字出现的次数。
#include <iostream>#include <fstream>#include <string>#include <map>using namespace std;int main(){ wifstream in("1.txt"); setlocale(LC_ALL, "");wchar_ttemp;map<wchar_t, int> cnt; while(!in.eof()){in >> temp; cnt[temp]++;}typedef map<wchar_t, int>::const_iterator map_iter;for(map_iter it = cnt.begin(); it != cnt.end(); ++it) { wprintf(L"%lc ", it -> first); cout << it -> second << endl; } return 0;}
0 0
- IOS应用本地化小结
- IOS应用本地化小结
- C++本地化小结
- iOS本地化学习小结
- 【C#】本地化两种方案
- c语言的本地化实现
- 本地化
- 本地化
- 本地化
- 本地化
- 本地化
- 本地化
- 本地化
- 嵌入式 C 编程 国际化和本地化 (ZZ)
- C语言中用GNU gettext实现本地化
- C型本地化 clocale(locale.h)
- C语言中用GNU gettext实现本地化
- C小结
- 如何给Ubuntu 安装Vmware Tools
- Merge k Sorted Lists ,优先级队列(堆)的使用
- [ZedBoard移植嵌入式Linux教程(1,2)]软硬件环境与搭建硬件工程
- 在linux下新增一块硬盘的操作
- iOS 静态库中使用类别(Category)
- C++本地化小结
- C语言基础语法
- 关于多系统的双硬盘的系统安装
- 黑马程序员--UI学习之用代码向你展示视图控制器(UIViewController)和导航控制器(UINavigationController)配合单例的使用
- C++文件读写详解(ofstream,ifstream,fstream)
- Windows环境下搭建HBase源码开发环境
- Codeforces 5C. Longest Regular Bracket Sequence
- jQueryEasyUI Messager基本使用
- ionic写helloworld步骤