|
|
@ -64,14 +64,14 @@ namespace |
|
|
|
|
|
|
|
static const size_t IconvBufSize = 64; |
|
|
|
|
|
|
|
std::string to_utf8_iconv(const std::string& charset, const std::string& s) |
|
|
|
std::string to_utf8_iconv(const sv& charset, const std::string& s) |
|
|
|
{ |
|
|
|
iconv_t ict = iconv_open("UTF-8", charset.c_str()); |
|
|
|
iconv_t ict = iconv_open("UTF-8", charset.data()); |
|
|
|
if(ict == (iconv_t)-1) |
|
|
|
{ |
|
|
|
if(errno==EINVAL) |
|
|
|
{ |
|
|
|
throw std::runtime_error("Cannot convert from charset \"" + charset + "\" to UTF-8."); |
|
|
|
throw std::runtime_error("Cannot convert from charset \"" + std::string(charset) + "\" to UTF-8."); |
|
|
|
}else{ |
|
|
|
throw std::runtime_error(std::string("Internal error: ") + strerror(errno) ); |
|
|
|
} |
|
|
@ -113,7 +113,7 @@ std::string to_utf8_iconv(const std::string& charset, const std::string& s) |
|
|
|
} // end of anonymous namespace
|
|
|
|
|
|
|
|
|
|
|
|
std::string to_utf8( const std::string& charset, const std::string& s) |
|
|
|
std::string to_utf8( const sv& charset, const std::string& s) |
|
|
|
{ |
|
|
|
std::string charset_upper{charset}; |
|
|
|
boost::algorithm::to_upper(charset_upper); |
|
|
|