摘要: CString urlEncode(CString s){int len = s.GetLength();char *out = new char[len*9+1];memset(out , 0 , len*9+1);int i , j;int ch = 0 ;static char myhex[0xFF+1][4]; //add by zhouzd 2008-10-06static bool isinital = false;if ( !isinital ){for ( i = 0 ; i <= 0xFF ; ++i ){myhex[i][0] = '%';sprint 阅读全文
posted @ 2012-11-23 18:27 郑文亮 阅读(2482) 评论(0) 推荐(0)
摘要: // pb.cpp : Defines the initialization routines for the DLL.//#include "stdafx.h"#include <string.h>#include "pb.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif////Note!////If this DLL is dynamically linked against the MFC//DLLs 阅读全文
posted @ 2012-11-23 16:29 郑文亮 阅读(413) 评论(0) 推荐(0)
摘要: 最近在C++编程中经常遇到需要多字节字符与宽字节字符相互转换的问题,一直自己贴那几句代码。觉得麻烦,于是就自己写了一个类来封装wchar_t与char类型间的转换,其他的,诸如:CString\ LPWSTR\TCHAR CHAR\LPSTR之间也是一样用#include <iostream> using namespace std; class CUser { public: CUser(); virtual~ CUser(); char* WcharToChar(wchar_t* wc);//宽字节转单字节 wchar_t* CharToWchar(char* c); //单字 阅读全文
posted @ 2012-11-23 13:32 郑文亮 阅读(20790) 评论(1) 推荐(1)
摘要: C语言原本是在英文环境中设计的,主要的字符集是7位的ASCII码,8位的byte(字节)是最常见的字符编码单位。但是国际化软件必须能够表示不同的字符,而这些字符数量庞大,无法使用一个字节编码。 C95标准化了两种表示大型字符集的方法:宽字符(wide character,该字符集内每个字符使用相同的位长)以及多字节字符(multibyte character,每个字符可以是一到多个字节不等,而某个字节序列的字符值由字符串或流(stream)所在的环境背景决定)。 自从1994年的增补之后,C语言不只提供char类型,还提供wchar_t类型(宽字符),此类型定义在stddef.h 头文件... 阅读全文
posted @ 2012-11-23 13:22 郑文亮 阅读(4189) 评论(0) 推荐(0)
摘要: 作者:朱金灿来源:http://blog.csdn.net/clever101 以前看《Window核心编程》,感觉多字节和宽字节之间还比较麻烦的,至少MultiByteToWideChar函数和WideCharToMultiByte函数有足够多的参数的意义让我们去理解。近日接触了ATL的一个很好的字符串的转换宏:A2W和W2A。用法很简单,A2W的用法:[cpp] view plaincopyprint?#include<atlconv.h> DoSomething(LPWSTRstr);//函数声明 USES_CONVERSION;DoSomething(A2W("S 阅读全文
posted @ 2012-11-23 11:34 郑文亮 阅读(473) 评论(0) 推荐(0)