Вот мой маленький примерчик.
Правда для UTF-8 <-> KOI8-R
//! Converting string from UTF-8 to KOI8-R or from KOI8-R to UTF-8
//! @return true if success
//! @utf2koi true if conversion from KOI8-R to UTF-8, false if otherwise
bool utf2koi(char *src, unsigned int src_len, char *dst, unsigned int dst_len, bool utf2koi)
{
iconv_t ic;
if ( utf2koi )
ic = iconv_open("KOI8-R","UTF-8");
else
ic = iconv_open("UTF-8","KOI8-R");
if ( ic == (iconv_t)(-1)) {
cerr << "[ DEBUG ] Error in iconv_open: " << strerror(errno) << endl;
return false;
}
size_t ret = iconv(ic,&src,&src_len ,&dst,&dst_len);
if ( ret == (size_t)(-1)) {
cerr << "[ DEBUG ] Error in iconv: " << strerror(errno) << endl;
iconv_close(ic);
return false;
}
iconv_close(ic);
return true;
}