#pragma once
#include <windows.h>
#include <string>
namespace Util{ //start namespace
int SEU_Rand(int ran); //自定义的随机数发生器
/************************************************************************/
/*
三种编码格式互转
UTF-8 <===> GB2312
∧ ∧
| |
| |
∨ ∨
Unicode
UTF-8和GB2312可以用strlen来计算长度
Unicode要wsclen(p)*2=字符串长度. 因为unicode一个ansi字符也占2字节. 一个汉字也占2字节.
*/
/************************************************************************/
//UTF-8到GB2312的转换,返回的指针要delete
char* UTF8_To_GB2312(const char* utf8);
//string版
std::string UTF8_To_GB2312( const std::string &utf8 );
//GB2312到UTF-8的转换,返回的指针要delete
char* GB2312_To_UTF8(const char* gb2312);
//string版
std::string GB2312_To_UTF8( const std::string &gb2312 );
char* UTF8_To_Unicode( IN const char* utf8, OUT int & len);//参数2是为了方便知道unicode的字符串长度.也可以用wsclen来计算该函数返回的unicode char*指针.来统计unicode的字符数.x2就是字符串长度
//string版
std::wstring UTF8_To_Unicode( const std::string &utf8 );
char* Unicode_To_UTF8(const char* unicode);
//string版
std::string Unicode_To_UTF8(const std::wstring &unicode );
//等同于MByteToWChar. 内部调用了MByteToWChar
char* GB2312_To_Unicode(const char* gb2312,int & len);
//string版
std::wstring GB2312_To_Unicode( const std::string &gb2312 );
//等同与WCharToMByte 内部调用了WCharToMByte
char* Unicode_To_GB2312(const char* unicode);
//string版
std::string Unicode_To_GB2312(const std::wstring &unicode );
/*
宽字符转多字节
注意返回的字符串不用后要delete
*/
CHAR* WCharToMByte(WCHAR* lpcwszStr); //其实就是unicode 转ansi/gb2312
/*
多字节转宽字符
注意返回的字符串不用后要delete
*/
WCHAR* MByteToWChar(CHAR* lpcstr);
static inline std::string convWith( const std::wstring &src );
static inline std::wstring convWith( const std::string &src );
}; //end namespace#pragma once
#include <windows.h>
#include <s