BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #89533同步于 2015/11/26
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

哪位大神能够实现vs2012环境下 utf-8到gbk2312的转化

xh06251220lx
2015/11/26镜像同步9 回复
使用multibytetowidechar windows.h下的 跪求讲解 和代码 发自〖iBYR-iOS客户端〗
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
xh06251220lx机器人#1 · 2015/11/26
ps百度上的都好不靠谱 根本就没法在我的电脑上运行 由于版本差距 和环境 讲解也是很难懂 无可奈何求解 【 在 xh06251220lx (深巷- depths°) 的大作中提到: 】 : 使用multibytetowidechar windows.h下的 跪求讲解 和代码 : : 发自〖iBYR-iOS客户端〗
fuxuemingzhu机器人#2 · 2015/11/26
我有 java的,楼主要不要?
xh06251220lx机器人#3 · 2015/11/26
(?????) 谢谢好心 必须得是cpp的 因为不太会如何从cpp调用java代码orz 【 在 fuxuemingzhu (负雪明烛) 的大作中提到: 】 : 我有 java的,楼主要不要? 发自〖iBYR-iOS客户端〗
FromMars机器人#4 · 2015/11/26
你说的是字符串转化还是?
xh06251220lx机器人#5 · 2015/11/26
嗯 字符串转化 【 在 FromMars (T_):) 的大作中提到: 】 : 你说的是字符串转化还是? 发自〖iBYR-iOS客户端〗
FromMars机器人#6 · 2015/11/26
不知道卤煮说的是不是字符串编码转换: //ANSI->Unicode WSTRING s2ws(const STRING &str) { int len; int slength = (int)str.length() + 1; len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), slength, 0, 0); wchar_t* buf = new wchar_t[len]; MultiByteToWideChar(CP_ACP, 0, str.c_str(), slength, buf, len); WSTRING temp(buf); delete[] buf; return temp.c_str(); } //ANSI<-Unicode STRING ws2s(const WSTRING wstr) { //int wlen= wcslen(wstr.c_str())+1; int wlen = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL); char *strbuf = new char[wlen + 1]; WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, strbuf, wlen, NULL, NULL); STRING str(strbuf); delete[] strbuf; return str; } /* 补充: #define WSTRING std::wstring #define STRING std::string */ 此外还有 USES_CONVERSION; WSTRING wstr =A2W(str.c_str()); STRING str =W2A(wstr .c_str(0); 【 在 xh06251220lx 的大作中提到: 】 : 使用multibytetowidechar windows.h下的 跪求讲解 和代码 : 发自〖iBYR-iOS客户端〗
FromMars机器人#7 · 2015/11/26
你看看我上一条回复 为啥说百度的不能用? 第一个方法就是我之前百度出来的 【 在 xh06251220lx 的大作中提到: 】 : 嗯 字符串转化 : 发自〖iBYR-iOS客户端〗
xh06251220lx机器人#8 · 2015/11/26
跪谢 么么哒 【 在 FromMars (T_):) 的大作中提到: 】 : 你看看我上一条回复 : 为啥说百度的不能用? : 第一个方法就是我之前百度出来的 : 发自〖iBYR-iOS客户端〗
mnhg123机器人#9 · 2015/11/26
两种方法 1使用转换宏 2MultiByteToWideChar和WideCharToMultiByte函数,把utf-8转换成wchar在转换成gbk。 发自「贵邮」