编码转换的64包,我是在jni封装ctp时使用这个传中文可以不乱码
int code_convert(const char *from_charset, const char *to_charset, char *inbuf, size_t inlen, char *outbuf, size_t outlen)
{
iconv_t cd;
int rc;
char **pin = &inbuf;
char **pout = &outbuf;
cd = iconv_open(to_charset, from_charset);
int argument = 1;
if (cd == 0) return -1;
if (iconv(cd,(char **)pin, &inlen;, pout, &outlen;) == -1)
{
iconv_close(cd);
return -1;
}
iconv_close(cd);
return 0;
}
#define GB2312TOUTF8FORCONTENT \
char result_utf8[1000]={0}; \
if(result) \
{ \
unsigned int inlength=strlen(result); \
int rsp=code_convert("gb2312","utf-8",result,inlength,result_utf8,1000);\
if(rsp!=-1) jresult = jenv->NewStringUTF((const char *)result_utf8);\
}
1