|
[code:1]
#include <iostream.h>
#include <iconv.h>
using namespace std;
int main(int argc, char *argv[])
{
char* f="GB2312";
char* t="UTF-8";
char* inbuf="你好,谢谢,测试,abcdefg";
char outbuf[4096];
char* outbuf_p=outbuf;
size_t inbuf_size=strlen(inbuf);
size_t outbuf_size=sizeof(outbuf);
iconv_t cd=iconv_open(t,f);
size_t result=iconv(cd,&inbuf,&inbuf_size,&outbuf_p,&outbuf_size);
cout<<result<<endl;
cout<<outbuf<<endl;
iconv_close(cd);
return EXIT_SUCCESS;
}
[/code:1] |
|