iconv源码和库的下载

libiconv - GNU Project - Free Software Foundation (FSF)
http://www.gnu.org/software/libiconv/

iconv源码在vs2013环境下的编译

本地环境是win7、vs2013,最近一次编译时2016年6月

1、打开vs2013的命令行工具(为了使用VC2013的缺省系统配置参数).
以下是本机路径示例,各机器类似:
D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\VS2013 开发人员命令提示
cd到D:/third\iconv 目录。

2、将iconv\srclib\stdbool_.h复制一份到iconv\srclib\stdbool.h,
并将刚复制的stdbool.h文件中的@HAVE__BOOL@ 替换为1

3、执行以下命令行
nmake -f Makefile.msvc NO_NLS=1 DLL=1 MFLAGS=-MD PREFIX=“D:/third/iconv/bin” IIPREFIX=“D:/third/iconv/bin”
nmake -f Makefile.msvc NO_NLS=1 DLL=1 DEBUG=1 MFLAGS=-MD PREFIX=“D:/third/iconv/bin” IIPREFIX=“D:/third/iconv/bin”

4、iconv.dll、iconv.lib生成在iconv\lib目录中。

iconv的字符集转换接口的封装简化

以下为封装后的h文件,无cpp文件


#if defined _MSC_VER && _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000#include "../iconv/include/iconv.h"#include <Windows.h>/** @brief 用iconv转换字符集
使用示例:
QString qt_file_name = "D:/中文目录/123.txt"; //utf8
std::string xml_file_name_local = CodePageInfor::Utf8ToLocal(qt_file_name.toStdString());
std::string xml_file_name_utf8 = CodePageInfor::LocalToUtf8(xml_file_name_local);
*/
class CodePageInfor{
public:int code_page_; /**< 代码页*/std::string name_; /**< 名称*/std::string display_name_; /**< 显示名称*/
public:CodePageInfor() :code_page_(0){}~CodePageInfor(){}CodePageInfor(const CodePageInfor &t):code_page_(t.code_page_), name_(t.name_), display_name_(t.display_name_){}CodePageInfor &operator=(const CodePageInfor &t){if (this == &t)return *this;code_page_ = t.code_page_;name_ = t.name_;display_name_ = t.display_name_;return *this;}CodePageInfor(const int code_page, const std::string &name, const std::string &display_name):code_page_(code_page), name_(name), display_name_(display_name){}
public:static int GetCurrentCodePage(){//std::locale::global(std::locale(""));//初始化//std::string s = std::locale().c_str();//后几位数值转换为intreturn GetACP();}static std::string CodePageToName(const int code_page_temp){typedef std::map<int, CodePageInfor> Int2CPMap;static Int2CPMap gInt2CPMap;static bool bini = false;if (!bini){gInt2CPMap.insert(Int2CPMap::value_type(37, CodePageInfor(37, "IBM037", "IBMEBCDIC(US-Canada)")));gInt2CPMap.insert(Int2CPMap::value_type(437, CodePageInfor(437, "IBM437", "OEMUnitedStates")));gInt2CPMap.insert(Int2CPMap::value_type(500, CodePageInfor(500, "IBM500", "IBMEBCDIC(International)")));gInt2CPMap.insert(Int2CPMap::value_type(708, CodePageInfor(708, "ASMO-708", "Arabic(ASMO708)")));gInt2CPMap.insert(Int2CPMap::value_type(720, CodePageInfor(720, "DOS-720", "Arabic(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(737, CodePageInfor(737, "ibm737", "Greek(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(775, CodePageInfor(775, "ibm775", "Baltic(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(850, CodePageInfor(850, "ibm850", "WesternEuropean(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(852, CodePageInfor(852, "ibm852", "CentralEuropean(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(855, CodePageInfor(855, "IBM855", "OEMCyrillic")));gInt2CPMap.insert(Int2CPMap::value_type(857, CodePageInfor(857, "ibm857", "Turkish(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(858, CodePageInfor(858, "IBM00858", "OEMMultilingualLatinI")));gInt2CPMap.insert(Int2CPMap::value_type(860, CodePageInfor(860, "IBM860", "Portuguese(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(861, CodePageInfor(861, "ibm861", "Icelandic(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(862, CodePageInfor(862, "DOS-862", "Hebrew(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(863, CodePageInfor(863, "IBM863", "FrenchCanadian(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(864, CodePageInfor(864, "IBM864", "Arabic(864)")));gInt2CPMap.insert(Int2CPMap::value_type(865, CodePageInfor(865, "IBM865", "Nordic(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(866, CodePageInfor(866, "cp866", "Cyrillic(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(869, CodePageInfor(869, "ibm869", "GreekModern(DOS)")));gInt2CPMap.insert(Int2CPMap::value_type(870, CodePageInfor(870, "IBM870", "IBMEBCDIC(MultilingualLatin-2)")));gInt2CPMap.insert(Int2CPMap::value_type(874, CodePageInfor(874, "windows-874", "Thai(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(875, CodePageInfor(875, "cp875", "IBMEBCDIC(GreekModern)")));gInt2CPMap.insert(Int2CPMap::value_type(932, CodePageInfor(932, "shift_jis", "Japanese(Shift-JIS)")));gInt2CPMap.insert(Int2CPMap::value_type(936, CodePageInfor(936, "gb2312", "ChineseSimplified(GB2312)")));gInt2CPMap.insert(Int2CPMap::value_type(949, CodePageInfor(949, "ks_c_5601-1987", "Korean")));gInt2CPMap.insert(Int2CPMap::value_type(950, CodePageInfor(950, "big5", "ChineseTraditional(Big5)")));gInt2CPMap.insert(Int2CPMap::value_type(1026, CodePageInfor(1026, "IBM1026", "IBMEBCDIC(TurkishLatin-5)")));gInt2CPMap.insert(Int2CPMap::value_type(1047, CodePageInfor(1047, "IBM01047", "IBMLatin-1")));gInt2CPMap.insert(Int2CPMap::value_type(1140, CodePageInfor(1140, "IBM01140", "IBMEBCDIC(US-Canada-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1141, CodePageInfor(1141, "IBM01141", "IBMEBCDIC(Germany-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1142, CodePageInfor(1142, "IBM01142", "IBMEBCDIC(Denmark-Norway-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1143, CodePageInfor(1143, "IBM01143", "IBMEBCDIC(Finland-Sweden-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1144, CodePageInfor(1144, "IBM01144", "IBMEBCDIC(Italy-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1145, CodePageInfor(1145, "IBM01145", "IBMEBCDIC(Spain-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1146, CodePageInfor(1146, "IBM01146", "IBMEBCDIC(UK-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1147, CodePageInfor(1147, "IBM01147", "IBMEBCDIC(France-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1148, CodePageInfor(1148, "IBM01148", "IBMEBCDIC(International-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1149, CodePageInfor(1149, "IBM01149", "IBMEBCDIC(Icelandic-Euro)")));gInt2CPMap.insert(Int2CPMap::value_type(1200, CodePageInfor(1200, "utf-16", "Unicode")));gInt2CPMap.insert(Int2CPMap::value_type(1201, CodePageInfor(1201, "unicodeFFFE", "Unicode(Big-Endian)")));gInt2CPMap.insert(Int2CPMap::value_type(1250, CodePageInfor(1250, "windows-1250", "CentralEuropean(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1251, CodePageInfor(1251, "windows-1251", "Cyrillic(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1252, CodePageInfor(1252, "Windows-1252", "WesternEuropean(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1253, CodePageInfor(1253, "windows-1253", "Greek(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1254, CodePageInfor(1254, "windows-1254", "Turkish(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1255, CodePageInfor(1255, "windows-1255", "Hebrew(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1256, CodePageInfor(1256, "windows-1256", "Arabic(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1257, CodePageInfor(1257, "windows-1257", "Baltic(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1258, CodePageInfor(1258, "windows-1258", "Vietnamese(Windows)")));gInt2CPMap.insert(Int2CPMap::value_type(1361, CodePageInfor(1361, "Johab", "Korean(Johab)")));gInt2CPMap.insert(Int2CPMap::value_type(10000, CodePageInfor(10000, "macintosh", "WesternEuropean(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10001, CodePageInfor(10001, "x-mac-japanese", "Japanese(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10002, CodePageInfor(10002, "x-mac-chinesetrad", "ChineseTraditional(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10003, CodePageInfor(10003, "x-mac-korean", "Korean(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10004, CodePageInfor(10004, "x-mac-arabic", "Arabic(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10005, CodePageInfor(10005, "x-mac-hebrew", "Hebrew(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10006, CodePageInfor(10006, "x-mac-greek", "Greek(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10007, CodePageInfor(10007, "x-mac-cyrillic", "Cyrillic(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10008, CodePageInfor(10008, "x-mac-chinesesimp", "ChineseSimplified(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10010, CodePageInfor(10010, "x-mac-romanian", "Romanian(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10017, CodePageInfor(10017, "x-mac-ukrainian", "Ukrainian(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10021, CodePageInfor(10021, "x-mac-thai", "Thai(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10029, CodePageInfor(10029, "x-mac-ce", "CentralEuropean(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10079, CodePageInfor(10079, "x-mac-icelandic", "Icelandic(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10081, CodePageInfor(10081, "x-mac-turkish", "Turkish(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(10082, CodePageInfor(10082, "x-mac-croatian", "Croatian(Mac)")));gInt2CPMap.insert(Int2CPMap::value_type(20000, CodePageInfor(20000, "x-Chinese-CNS", "ChineseTraditional(CNS)")));gInt2CPMap.insert(Int2CPMap::value_type(20001, CodePageInfor(20001, "x-cp20001", "TCATaiwan")));gInt2CPMap.insert(Int2CPMap::value_type(20002, CodePageInfor(20002, "x-Chinese-Eten", "ChineseTraditional(Eten)")));gInt2CPMap.insert(Int2CPMap::value_type(20003, CodePageInfor(20003, "x-cp20003", "IBM5550Taiwan")));gInt2CPMap.insert(Int2CPMap::value_type(20004, CodePageInfor(20004, "x-cp20004", "TeleTextTaiwan")));gInt2CPMap.insert(Int2CPMap::value_type(20005, CodePageInfor(20005, "x-cp20005", "WangTaiwan")));gInt2CPMap.insert(Int2CPMap::value_type(20105, CodePageInfor(20105, "x-IA5", "WesternEuropean(IA5)")));gInt2CPMap.insert(Int2CPMap::value_type(20106, CodePageInfor(20106, "x-IA5-German", "German(IA5)")));gInt2CPMap.insert(Int2CPMap::value_type(20107, CodePageInfor(20107, "x-IA5-Swedish", "Swedish(IA5)")));gInt2CPMap.insert(Int2CPMap::value_type(20108, CodePageInfor(20108, "x-IA5-Norwegian", "Norwegian(IA5)")));gInt2CPMap.insert(Int2CPMap::value_type(20127, CodePageInfor(20127, "us-ascii", "US-ASCII")));gInt2CPMap.insert(Int2CPMap::value_type(20261, CodePageInfor(20261, "x-cp20261", "T.61")));gInt2CPMap.insert(Int2CPMap::value_type(20269, CodePageInfor(20269, "x-cp20269", "ISO-6937")));gInt2CPMap.insert(Int2CPMap::value_type(20273, CodePageInfor(20273, "IBM273", "IBMEBCDIC(Germany)")));gInt2CPMap.insert(Int2CPMap::value_type(20277, CodePageInfor(20277, "IBM277", "IBMEBCDIC(Denmark-Norway)")));gInt2CPMap.insert(Int2CPMap::value_type(20278, CodePageInfor(20278, "IBM278", "IBMEBCDIC(Finland-Sweden)")));gInt2CPMap.insert(Int2CPMap::value_type(20280, CodePageInfor(20280, "IBM280", "IBMEBCDIC(Italy)")));gInt2CPMap.insert(Int2CPMap::value_type(20284, CodePageInfor(20284, "IBM284", "IBMEBCDIC(Spain)")));gInt2CPMap.insert(Int2CPMap::value_type(20285, CodePageInfor(20285, "IBM285", "IBMEBCDIC(UK)")));gInt2CPMap.insert(Int2CPMap::value_type(20290, CodePageInfor(20290, "IBM290", "IBMEBCDIC(Japanesekatakana)")));gInt2CPMap.insert(Int2CPMap::value_type(20297, CodePageInfor(20297, "IBM297", "IBMEBCDIC(France)")));gInt2CPMap.insert(Int2CPMap::value_type(20420, CodePageInfor(20420, "IBM420", "IBMEBCDIC(Arabic)")));gInt2CPMap.insert(Int2CPMap::value_type(20423, CodePageInfor(20423, "IBM423", "IBMEBCDIC(Greek)")));gInt2CPMap.insert(Int2CPMap::value_type(20424, CodePageInfor(20424, "IBM424", "IBMEBCDIC(Hebrew)")));gInt2CPMap.insert(Int2CPMap::value_type(20833, CodePageInfor(20833, "x-EBCDIC-KoreanExtended", "IBMEBCDIC(KoreanExtended)")));gInt2CPMap.insert(Int2CPMap::value_type(20838, CodePageInfor(20838, "IBM-Thai", "IBMEBCDIC(Thai)")));gInt2CPMap.insert(Int2CPMap::value_type(20866, CodePageInfor(20866, "koi8-r", "Cyrillic(KOI8-R)")));gInt2CPMap.insert(Int2CPMap::value_type(20871, CodePageInfor(20871, "IBM871", "IBMEBCDIC(Icelandic)")));gInt2CPMap.insert(Int2CPMap::value_type(20880, CodePageInfor(20880, "IBM880", "IBMEBCDIC(CyrillicRussian)")));gInt2CPMap.insert(Int2CPMap::value_type(20905, CodePageInfor(20905, "IBM905", "IBMEBCDIC(Turkish)")));gInt2CPMap.insert(Int2CPMap::value_type(20924, CodePageInfor(20924, "IBM00924", "IBMLatin-1")));gInt2CPMap.insert(Int2CPMap::value_type(20932, CodePageInfor(20932, "EUC-JP", "Japanese(JIS0208-1990and0212-1990)")));gInt2CPMap.insert(Int2CPMap::value_type(20936, CodePageInfor(20936, "x-cp20936", "ChineseSimplified(GB2312-80)")));gInt2CPMap.insert(Int2CPMap::value_type(20949, CodePageInfor(20949, "x-cp20949", "KoreanWansung")));gInt2CPMap.insert(Int2CPMap::value_type(21025, CodePageInfor(21025, "cp1025", "IBMEBCDIC(CyrillicSerbian-Bulgarian)")));gInt2CPMap.insert(Int2CPMap::value_type(21866, CodePageInfor(21866, "koi8-u", "Cyrillic(KOI8-U)")));gInt2CPMap.insert(Int2CPMap::value_type(28591, CodePageInfor(28591, "iso-8859-1", "WesternEuropean(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28592, CodePageInfor(28592, "iso-8859-2", "CentralEuropean(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28593, CodePageInfor(28593, "iso-8859-3", "Latin3(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28594, CodePageInfor(28594, "iso-8859-4", "Baltic(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28595, CodePageInfor(28595, "iso-8859-5", "Cyrillic(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28596, CodePageInfor(28596, "iso-8859-6", "Arabic(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28597, CodePageInfor(28597, "iso-8859-7", "Greek(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28598, CodePageInfor(28598, "iso-8859-8", "Hebrew(ISO-Visual)")));gInt2CPMap.insert(Int2CPMap::value_type(28599, CodePageInfor(28599, "iso-8859-9", "Turkish(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28603, CodePageInfor(28603, "iso-8859-13", "Estonian(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(28605, CodePageInfor(28605, "iso-8859-15", "Latin9(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(29001, CodePageInfor(29001, "x-Europa", "Europa")));gInt2CPMap.insert(Int2CPMap::value_type(38598, CodePageInfor(38598, "iso-8859-8-i", "Hebrew(ISO-Logical)")));gInt2CPMap.insert(Int2CPMap::value_type(50220, CodePageInfor(50220, "iso-2022-jp", "Japanese(JIS)")));gInt2CPMap.insert(Int2CPMap::value_type(50221, CodePageInfor(50221, "csISO2022JP", "Japanese(JIS-Allow1byteKana)")));gInt2CPMap.insert(Int2CPMap::value_type(50222, CodePageInfor(50222, "iso-2022-jp", "Japanese(JIS-Allow1byteKana-SO/SI)")));gInt2CPMap.insert(Int2CPMap::value_type(50225, CodePageInfor(50225, "iso-2022-kr", "Korean(ISO)")));gInt2CPMap.insert(Int2CPMap::value_type(50227, CodePageInfor(50227, "x-cp50227", "ChineseSimplified(ISO-2022)")));gInt2CPMap.insert(Int2CPMap::value_type(51932, CodePageInfor(51932, "euc-jp", "Japanese(EUC)")));gInt2CPMap.insert(Int2CPMap::value_type(51936, CodePageInfor(51936, "EUC-CN", "ChineseSimplified(EUC)")));gInt2CPMap.insert(Int2CPMap::value_type(51949, CodePageInfor(51949, "euc-kr", "Korean(EUC)")));gInt2CPMap.insert(Int2CPMap::value_type(52936, CodePageInfor(52936, "hz-gb-2312", "ChineseSimplified(HZ)")));gInt2CPMap.insert(Int2CPMap::value_type(54936, CodePageInfor(54936, "GB18030", "ChineseSimplified(GB18030)")));gInt2CPMap.insert(Int2CPMap::value_type(57002, CodePageInfor(57002, "x-iscii-de", "ISCIIDevanagari")));gInt2CPMap.insert(Int2CPMap::value_type(57003, CodePageInfor(57003, "x-iscii-be", "ISCIIBengali")));gInt2CPMap.insert(Int2CPMap::value_type(57004, CodePageInfor(57004, "x-iscii-ta", "ISCIITamil")));gInt2CPMap.insert(Int2CPMap::value_type(57005, CodePageInfor(57005, "x-iscii-te", "ISCIITelugu")));gInt2CPMap.insert(Int2CPMap::value_type(57006, CodePageInfor(57006, "x-iscii-as", "ISCIIAssamese")));gInt2CPMap.insert(Int2CPMap::value_type(57007, CodePageInfor(57007, "x-iscii-or", "ISCIIOriya")));gInt2CPMap.insert(Int2CPMap::value_type(57008, CodePageInfor(57008, "x-iscii-ka", "ISCIIKannada")));gInt2CPMap.insert(Int2CPMap::value_type(57009, CodePageInfor(57009, "x-iscii-ma", "ISCIIMalayalam")));gInt2CPMap.insert(Int2CPMap::value_type(57010, CodePageInfor(57010, "x-iscii-gu", "ISCIIGujarati")));gInt2CPMap.insert(Int2CPMap::value_type(57011, CodePageInfor(57011, "x-iscii-pa", "ISCIIPunjabi")));gInt2CPMap.insert(Int2CPMap::value_type(65000, CodePageInfor(65000, "utf-7", "Unicode(UTF-7)")));gInt2CPMap.insert(Int2CPMap::value_type(65001, CodePageInfor(65001, "utf-8", "Unicode(UTF-8)")));gInt2CPMap.insert(Int2CPMap::value_type(65005, CodePageInfor(65005, "utf-32", "Unicode(UTF-32)")));gInt2CPMap.insert(Int2CPMap::value_type(65006, CodePageInfor(65006, "utf-32BE", "Unicode(UTF-32Big-Endian)")));//bini = true;}Int2CPMap::iterator i = gInt2CPMap.find(code_page_temp);if (i != gInt2CPMap.end()){return i->second.name_;}return "";}static std::string GetCurrentCodePageName(){return CodePageToName(GetCurrentCodePage());}static std::string LocalToUtf8(const std::string &str){std::string cur_name = CodePageInfor::GetCurrentCodePageName();if (cur_name.length() == 0){return "";}iconv_t cd = iconv_open("utf-8", cur_name.c_str());if (cd == 0){return "";}const char *inbuftt = str.c_str();const char *inbuf = inbuftt;size_t inlen = strlen(inbuf);if (inlen == 0){iconv_close(cd);return "";}size_t outlen = inlen * 6;char *outbuf = new char[outlen];//长度改成动态长度,考虑inlen乘以6if (outbuf == NULL){iconv_close(cd);return "";}memset(outbuf, 0, outlen);char *outbuftt = outbuf;int iconv_ret = iconv(cd, &inbuf, &inlen, &outbuftt, &outlen);if (iconv_ret == -1){iconv_close(cd);if (outbuf){delete[] outbuf;}return "";}else{std::string str_ret(outbuf);iconv_close(cd);if (outbuf){delete[] outbuf;}return str_ret;}}static std::string Utf8ToLocal(const std::string &str){std::string cur_name = CodePageInfor::GetCurrentCodePageName();if (cur_name.length() == 0){return "";}iconv_t cd = iconv_open(cur_name.c_str(), "utf-8");if (cd == 0){return "";}const char *inbuftt = str.c_str();        const char *inbuf = inbuftt;size_t inlen = strlen(inbuf);if (inlen == 0){iconv_close(cd);return "";}size_t outlen = inlen * 6;char *outbuf = new char[outlen];//长度改成动态长度,考虑inlen乘以6if (outbuf == NULL){iconv_close(cd);return "";}memset(outbuf, 0, outlen);iconv(cd, NULL, NULL, NULL, NULL);char *outbuftt = outbuf;int iconv_ret = iconv(cd, &inbuf, &inlen, &outbuftt, &outlen);if (iconv_ret == -1){iconv_close(cd);if (outbuf){delete[] outbuf;}return "";}else{std::string str_ret(outbuf);iconv_close(cd);if (outbuf){delete[] outbuf;}return str_ret;}}
};

cpp iconv 字符集转换函数相关推荐

  1. iconv 判断字符编码_iconv 字符集转换报错

    iconv 字符集转换出错 本帖最后由 zw91683 于 2014-02-26 15:59:48 编辑 最近有个项目在用字符集转换,网上查了下iconv的用法,直接拿过来用,发现运行一直出错,代码如 ...

  2. php中iconv函数使用_字符集转换编码

    php中iconv函数介绍 iconv函数库能够完成各种字符集间的转换,是php编程中不可缺少的基础函数库. 1.下载libiconv函数库http://ftp.gnu.org/pub/gnu/lib ...

  3. 使用iconv编程进行字符集转换

    使用iconv编程进行字符集转换 摘自:https://www.cnblogs.com/lancidie/archive/2013/04/12/3016965.html Linux上进行编码转换时,既 ...

  4. iconv()和mb_conver_encoding()字符编码转换函数

    2019独角兽企业重金招聘Python工程师标准>>> 一. `string iconv ( string $in_charset , string $out_charset , s ...

  5. 宽字符集(unicode)说明以及转换函数

    宽字符集(unicode)说明以及转换函数 1.为什么要使用Unicode? (1) 可以很容易地在不同语言之间进行数据交换. (2) 使你能够分配支持所有语言的单个二进制.exe文件或DLL文件. ...

  6. GBase 8c 函数与操作符——32-字符集支持 | 服务器与客户端之间的自动字符集转换

    启用自动字符集转换功能,需要告知数据库客户端使用的字符集/编码: 用gsql里的\encoding命令.例如,把编码改变为SJIS: \encoding SJIS libpq中提供函数控制客户端编码. ...

  7. php字符集编码转换,php编码转换_php编码转换函数

    摘要 腾兴网为您分享:php编码转换函数,云端学习,鱼乐贝贝,优品多多,一路捞等软件知识,以及天地图厦门,快剪辑app,java学习手册,酷狗2010,王者荣耀点券软件,xmart,有声小说软件,mp ...

  8. php iconv 空格,PHP_PHP中iconv函数转码时截断字符问题的解决方法,iconv是转换编码的,但是在中 - phpStudy...

    PHP中iconv函数转码时截断字符问题的解决方法 iconv是转换编码的,但是在中文转码时候出现显示不全问题. iconv("UTF-8","GB2312//IGNOR ...

  9. mbstowcs 和 wcstombs函数:C语言提供的宽字符和多字节字符转换函数

    C语言中的多字节字符与宽字符 字符型char只占八位,存储ascii码的,而宽字符型是为了存储多国语言的代码unicode,包括中文,法语德语什么的,8位256种不够用了 C语言原本是在英文环境中设计 ...

最新文章

  1. golang源码分析:调度器chan调度
  2. 苹果Think Different广告
  3. JVM Server与Client运行模式
  4. linux进程打开链接数,Linux 进程打开最大文件连接数Too many open files
  5. BZOJ 2440 完全平方数(莫比乌斯-容斥原理)
  6. Jeecg - MiniDao专题讲解公开课(2013-08-22 晚8:30-10:30 )
  7. 如何查询日志文件中的所有ip,正则表达式
  8. 戴尔服务器t330可以用无线网卡吗,DELL T330服务器安装windows2008R2系统
  9. 抖音下载小助手GUI版
  10. 你绝对不知道的JS冷知识
  11. 博客园签名档图片圆角美化
  12. 第十七届全国大学生智能汽车竞赛百度创意组来啦
  13. r720换固态硬盘后如何重装系统_换SSD学会这招后再也不用重装系统了!
  14. FFmpeg 源码之分配与释放 AVPacket 常用函数
  15. Web前端 - HTML
  16. 【HEC-RAS水动力】HEC-RAS 1D基本原理(恒定流及非恒定流)
  17. iOS自动化测试-环境搭建
  18. png.h缺失 - 安装
  19. 使用fontmin 进行字体压缩
  20. 【大物实验数据处理】分光计的调节与应用,C++

热门文章

  1. eclipse 找不到 tomcat 的解决方案
  2. 狂砸200多亿,腾讯的医疗野心
  3. ssr Android简书,渲染篇一:服务端渲染(SSR)
  4. Intermec PX4I 高性能条码打印机 助力信息化
  5. postman编写记录
  6. ifttt_选择IFTTT平台的7个技巧
  7. ESP32基于Arduino框架下U8g2驱动I2C OLED 时间显示
  8. 颜料、画布LHAMA测试认证及ASTM D4236测试介绍。
  9. 昨天,我发布了微博寻人二代系统-微博寻人链
  10. 95后自述,00后都这么卷了吗?