- #include
<sys/types.h> - #include
<iconv.h> - #include
<stdio.h> - using
namespace std; - char
* UTF8toANSI(const std::string &from){ -
char *inbuf=const_cast<char*>(from.c_str()); -
size_t inlen = strlen(inbuf); -
size_t outlen = inlen *4; -
char *outbuf = (char *)malloc(inlen * 4 ); -
bzero( outbuf, inlen * 4); -
char *in = inbuf; -
char *out = outbuf; -
iconv_t cd=iconv_open("GBK","UTF-8"); -
iconv(cd,&in,&inlen,&out,&outlen); -
iconv_close(cd); -
return outbuf; - }
linux下使用iconv转换编码:UTF8转GBK
最新推荐文章于 2024-01-07 08:00:00 发布