WideCharToMultiByte
/
#include "stdafx.h"
#include <string.h>
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
int main(void)
{
}
API 函数WideCharToMultiByte参数说明
第一个参数:指定要转换成的字符集代码页,它可以是任何已经安装的或系统自带的字符集,你也可以使用如下所示代码页之一。
第二个参数:指定如何处理没有转换的字符,但不设此参数函数会运行的更快一些,我都是把它设为0。
第三个参数:待转换的宽字符串。
第四个参数:待转换宽字符串的长度,-1表示转换到字符串结尾。
第五个参数:接收转换后输出新串的缓冲区。
第六个参数:输出缓冲区大小。
第七个参数:指向字符的指针。
第八个参数:开关变量的指针,用以表明是否使用过默认字符,一般设为0。
PS:如果还有不明白的地方,请参考:http://topic.csdn.net/u/20090201/22/aef91c79-7008-4772-b55d-a19990215afc.html
wifstream fin(path);
fin.seekg(0, ios::beg);
std::ostringstream oss;
std::string szUrl;
//将CString转为std::string
CString s= S;
DWORD num = WideCharToMultiByte(CP_ACP,0,s,-1,NULL,0,NULL,0);
char* chr = new char[num];
memset(chr, 0, num * sizeof(char));
WideCharToMultiByte(CP_ACP, 0, s.GetBuffer(), -1, chr, num, NULL, NULL);
oss << "aa" << chr << "bb";
oss << get();
szUrl = oss.str();