C++常用函数
来源:互联网 发布:域名注册必须实名吗 编辑:程序博客网 时间:2024/06/16 18:56
ut-8f转unicode
wstring UTF8ToUnicode(const string&str){int len =0;len = str.length();int unicodeLen = MultiByteToWideChar(CP_UTF8,0,str.c_str(),-1,NULL,0);wchar_t *pUnicode = new wchar_t[unicodeLen+1];memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t));MultiByteToWideChar(CP_UTF8,0,str.c_str(),-1,(WCHAR*)pUnicode,unicodeLen);wstring rt;rt = (wchar_t*)pUnicode;delete []pUnicode;return rt;}
unicode转UTF-8
string UnicodeToUTF(const wstring&str){char* pElementText;int len =0;len = WideCharToMultiByte(CP_UTF8,0,str.c_str(),-1,NULL,0,NULL,NULL);pElementText = new char[len+1];memset(pElementText,0,(len+1)*sizeof(char));WideCharToMultiByte(CP_UTF8,0,str.c_str(),-1,pElementText,len,NULL,NULL);string strText;strText = pElementText;delete[] pElementText;return strText;}
//跨平台
string ws2s(const wstring ws){string curLocale = setlocale(LC_ALL,NULL);setlocale(LC_ALL,"chs");const wchar_t* Sourse = ws.c_str();size_t dSize = ws.size() * 2 + 1;char* dest = new char[dSize];memset(dest,0,dSize);wcstombs(dest,Sourse,dSize);string result = dest;delete[] dest;setlocale(LC_ALL,curLocale.c_str());return result;}wstring s2ws(const string&s){string curLocale = setlocale(LC_ALL,NULL);setlocale(LC_ALL,"chs");const char* source = s.c_str();size_t dSize = s.size()+1;wchar_t* dest = new wchar_t[dSize];memset(dest,0,dSize);mbstowcs(dest,source,dSize);wstring result = dest;delete[] dest;setlocale(LC_ALL,curLocale.c_str());return result;}
- C#.net常用函数
- c#.net常用函数
- c 常用函数说明
- Linux 常用C函数
- C常用函数
- C/C++常用函数
- linux 常用c函数
- C 常用函数解析
- C 常用字符串函数
- C# 常用字符串函数
- c常用字符串函数
- c常用函数实现
- 常用c 函数
- C 常用函数集
- C语言常用函数
- LINUX常用C函数
- C语言常用函数
- linux 常用c 函数
- 从萌芽到融合 智能建筑发展四阶段分析
- lunix下的读写文件操作
- JAVA连接oracle数据库的三种方式
- (转)oracle审计—精细审计(Fine-Grained Audit)
- android Settings中About Phone的Model number等信息的修改
- C++常用函数
- null、 undefined、 0、 false、 "" 谁等于谁
- 设计模式学习之装饰模式
- Hey, C Is a Functional Language Too!
- hibernate引用查询和联合查询
- android 判断当前是否是飞行模式和侦听airplane mode change
- JavaScript 这类弱类型的语言,在判断相等方面很麻烦,明明不是一个东西,却相等了。这里通过示例展示 null、 undefined、 0、 false、 "" 的相等情况。 var arr
- a plan for 2012--2013
- 多成绩判断及格