随笔分类 -  VC++ Unicode编码应用

摘要:https://msdn.microsoft.com/en-us/library/78zh94ax.aspx 阅读全文
posted @ 2017-08-06 23:59 findumars 阅读(1565) 评论(0) 推荐(0) 编辑
摘要:std::wstring ws=L"kkkk"; int il=ws.length(); int ia=sizeof(ws); int ib=sizeof("dddd"); int ic=sizeof(L"kkkk");输出为 il=4,ia=32,ib=5,ic=10为什么ia=32 ?wstri 阅读全文
posted @ 2017-08-06 22:04 findumars 阅读(1126) 评论(0) 推荐(0) 编辑
摘要:windows平台下微软的库自带了一些api可用于几种编码格式间的互相转码,其实可以用一个iconv开源跨平台的转码库,那个方法更方便且统一。 使用前要引入头文件和命名空间 [cpp] view plain copy print? #include <iostream> #include <stri 阅读全文
posted @ 2017-07-28 22:05 findumars 阅读(2075) 评论(0) 推荐(0) 编辑
摘要:TCHAR是一种字符串类型,它让你在以MBCS和UNNICODE来build程序时可以使用同样的代码,不需要使用繁琐的宏定义来包含你的代码,而char代表ASCII的字符 #ifdef UNICODE typedef wchar_t TCHAR; #else typedef char TCHAR; 阅读全文
posted @ 2017-07-28 21:36 findumars 阅读(2192) 评论(0) 推荐(0) 编辑
摘要:在C++中字符串类的string的模板原型是basic_string 第一个参数_Elem表示类型。第二个参数traits的缺省值使用char_traits类型,定义了类型和字符操作的函数,如比较、等价、分配等。第三个参数_Ax的默认值是allocator类,表示了内存模式,不同的内存结构将操作指针 阅读全文
posted @ 2017-07-13 20:41 findumars 阅读(2116) 评论(0) 推荐(0) 编辑
摘要:简介 1、这段代码只考虑在小端序情况下的转换(一般的机器都是的)。2、这段代码需要C++11的支持(只是用到了u16string),如果不支持,可以添加下面代码 typedef uint16_t char16_t; typedef std::basic_string<char16_t> utfcon 阅读全文
posted @ 2017-07-05 22:53 findumars 阅读(1061) 评论(0) 推荐(0) 编辑
摘要:String的本质是一个char*,只是以类的形式提供,使用起来比较方便 Class String {private: char* m_data;}摘自《后台开发 核心技术与应用实践__徐晓鑫》p68 方便之处:C++提供的由C++字符串转换成对应的C字符串的方法是使用data(), c_str() 阅读全文
posted @ 2017-06-27 16:27 findumars 阅读(516) 评论(0) 推荐(0) 编辑
摘要:两个使用的函数: 1,UTF8转化为Unicode,inline为了编译后更快运行,老用到了,返回字符串为了使用链式表达式 inline WCHAR *UTF8ToUnicode(const char *str) throw() { int i = MultiByteToWideChar(CP_UT 阅读全文
posted @ 2017-06-09 19:43 findumars 阅读(2276) 评论(0) 推荐(0) 编辑
摘要:dddd 阅读全文
posted @ 2017-05-08 19:09 findumars 阅读(203) 评论(0) 推荐(0) 编辑
摘要:打印所有字符的GBK编码: http://www.cnblogs.com/findumars/p/5557239.html 阅读全文
posted @ 2017-04-03 04:51 findumars 阅读(1303) 评论(0) 推荐(0) 编辑
摘要:以gcc为例,它有三个命令选项:-finput-charset=gb18030-fexec-charset=utf-8-fwide-exec-charset=utf32顾名思议,input-charset指的是源文件中字符串常量(字面量)的编码,exec-charset是运行时字符编码,也就是可执行 阅读全文
posted @ 2017-03-27 16:11 findumars 阅读(1441) 评论(0) 推荐(0) 编辑
摘要:很多方案是采用GetVersion、GetVersionEx这两个API来查询操作系统的版本号来判断当前的操作系统是Windows系列中的哪个,在Win10没有出现前,这种方法是行的通的,但是Win10出现后此方法对于判断Win10就不准了。 在此提供一个读取注册表的方法,已经验证过可行: [cpp 阅读全文
posted @ 2017-03-17 22:25 findumars 阅读(545) 评论(0) 推荐(0) 编辑
摘要:就在近日,Facebook宣布开源了内部使用的C++底层库,总称folly,包括散列、字符串、向量、内存分配、位处理等,以满足大规模高性能的需求。 这里是folly的github地址:https://github.com/facebook/folly 在folly项目的Overview.md中,谈到 阅读全文
posted @ 2017-02-21 06:00 findumars 阅读(646) 评论(0) 推荐(0) 编辑
摘要:平时都用的是char数组,基本忘记了char*数组和char**数组该怎么用了 char s1[10]; s1[0] s1[1]等都是char s1是char*,等同于&s1[0] char*s2[10]; s2[0] s2[1]等都是char* *s2[0] *s2[1]等都是char,是s2[0 阅读全文
posted @ 2017-02-18 01:03 findumars 阅读(3714) 评论(0) 推荐(0) 编辑
摘要:Making wchar_t work on Linux, OS X and Windows for CMarkup release 10.1 I learned a couple of humble lessons, and I expect I'll be posting more here a 阅读全文
posted @ 2017-02-16 22:30 findumars 阅读(952) 评论(1) 推荐(0) 编辑
摘要:Of Linux on wfopen (open wide-character version of the file name and mode) to achieve Not directly available on Linux wfopen function is used to open 阅读全文
posted @ 2017-02-16 01:11 findumars 阅读(1037) 评论(0) 推荐(0) 编辑
摘要:代码页没有进行设置。需要调用locale.h 中定义的一个函数设置默认的代码页 _tsetlocale(LC_ALL,_T(""));//设置代码页 wcstombs(sendBuf,strSendData,sendLen); setlocale(LC_ALL,"C"); http://blog.c 阅读全文
posted @ 2017-02-15 23:50 findumars 阅读(409) 评论(0) 推荐(0) 编辑
摘要:Example 1234567891011121314151617181920212223242526272829303132 /* setlocale example */ #include <stdio.h> /* printf */ #include <time.h> /* time_t, s 阅读全文
posted @ 2017-02-15 21:43 findumars 阅读(1481) 评论(0) 推荐(0) 编辑
摘要:Multibyte characters Multibyte strings http://www.cplusplus.com/reference/cstdlib/ http://www.cplusplus.com/reference/cwchar/wcrtomb/ 阅读全文
posted @ 2017-02-15 21:39 findumars 阅读(307) 评论(0) 推荐(0) 编辑
摘要:Standard C 语言标准函数库速查 (Cheat Sheet) Standard C 语言标准函数库速查 (Cheat Sheet) wcstombs 函数说明 #include <stdlib.h> size_t mbstowcs(wchar_t *pwcs, const char *s, 阅读全文
posted @ 2017-02-11 00:41 findumars 阅读(1300) 评论(0) 推荐(1) 编辑