From b7a15998457fbe15a56bbb2b017ce254e7c8a6ac Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 19 Nov 2015 11:15:32 -0300 Subject: [PATCH] removed iconv dependency from pe_bliss --- tools/pe_bliss/SCsub | 1 - tools/pe_bliss/utils.cpp | 44 ++++++++++------------------------------ 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/tools/pe_bliss/SCsub b/tools/pe_bliss/SCsub index 8173769c39c..34524f10efb 100644 --- a/tools/pe_bliss/SCsub +++ b/tools/pe_bliss/SCsub @@ -1,6 +1,5 @@ Import('env') env.add_source_files(env.tool_sources,"*.cpp") -env.Append(LIBS=["iconv"]) Export('env') diff --git a/tools/pe_bliss/utils.cpp b/tools/pe_bliss/utils.cpp index 00a20ef6f25..e6a75d54978 100644 --- a/tools/pe_bliss/utils.cpp +++ b/tools/pe_bliss/utils.cpp @@ -23,9 +23,6 @@ #include "utils.h" #include "pe_exception.h" -#ifndef PE_BLISS_WINDOWS -#include -#endif namespace pe_bliss { @@ -50,22 +47,13 @@ const u16string pe_utils::to_ucs2(const std::wstring& str) if(str.empty()) return ret; - ret.resize(str.length()); - - iconv_t conv = iconv_open("UCS-2", "WCHAR_T"); - if(conv == reinterpret_cast(-1)) - throw pe_exception("Error opening iconv", pe_exception::encoding_convertion_error); - - size_t inbytesleft = str.length() * sizeof(wchar_t); - size_t outbytesleft = ret.length() * sizeof(unicode16_t); - const wchar_t* in_pos = str.c_str(); - unicode16_t* out_pos = &ret[0]; - - size_t result = iconv(conv, const_cast(reinterpret_cast(&in_pos)), &inbytesleft, reinterpret_cast(&out_pos), &outbytesleft); - iconv_close(conv); + int len = str.length(); - if(result == static_cast(-1)) - throw pe_exception("Iconv error", pe_exception::encoding_convertion_error); + ret.resize(len); + + for(int i=0;i(-1)) - throw pe_exception("Error opening iconv", pe_exception::encoding_convertion_error); - - size_t inbytesleft = str.length() * sizeof(unicode16_t); - size_t outbytesleft = ret.length() * sizeof(wchar_t); - const unicode16_t* in_pos = str.c_str(); - wchar_t* out_pos = &ret[0]; - - size_t result = iconv(conv, const_cast(reinterpret_cast(&in_pos)), &inbytesleft, reinterpret_cast(&out_pos), &outbytesleft); - iconv_close(conv); - - if(result == static_cast(-1)) - throw pe_exception("Iconv error", pe_exception::encoding_convertion_error); + + for(int i=0;i