////////////////////////////////////////////////// //// / の#include <iconv.h> する#include <STDLIB.H> する#include <stdio.hの> INT code_convert(CHAR * from_charset、CHAR * to_charset、CHAR inlen * INBUF、size_tの、CHAR * outbufを、size_tのoutlenは) { iconv_t CD。int型のrc; 文字 **ピン=&INBUF。 文字 ** POUT =&outbufを。 CD = iconv_open(to_charset、from_charset)。 もし(CD == 0 ) リターン - 1。; IF(outlenは&)==ためのiconv(inlen CD、PIN、および、Poutと、 - 1。 ) リターン - 1。; はiconv_close(CD); 戻り 0 ; } // UTF8コードGB2312コードに INT U2G(CHAR * INBUF、INT inlen、CHAR * outbufを,, INT outlenは用) { 戻り code_convert(" UTF8 "、" 2312 " outlenはため、INBUF、inlen、outbufを,,); } // GB2312コードUTF8に INT G2U(CHAR* INBUF、size_tのinlen、CHAR * outbufを、size_tのoutlenは) { 戻り code_convert(" 2312 "、" UTF-8 " 、INBUF、inlen、outbufを、outlenは)。 } // UTF8转为GBK のstd :: 文字列 U2A(CONST 文字 * INBUF) { int型 inlen = STRLEN(INBUF)。 文字列strRet; strRet.resize(inlen * 2 + 2 )。 もし(code_convert(" UTF-8 "、" GBK"、はconst_cast < CHAR *>(INBUF)、inlen、&strRet [ 0 ]、strRet.size())) リターンINBUF; リターンstrRet; } // GBK转为UTF8 のstd :: 文字列 A2U(CONST 文字 * INBUF) { INT inlen = STRLEN(INBUF); ストリングstrRet; strRet.resize(inlen * 2 + 2 ) であれば(code_convert(" GBK "、" UTF-8 "、はconst_cast < チャー*>(INBUF)、inlen、&strRet [ 0 ]、strRet.size())) リターンINBUF。 返すstrRetを。 }