goldendict-ng/iconv.hh

51 lines
1.3 KiB
C++
Raw Normal View History

2012-02-20 21:47:14 +00:00
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __ICONV_HH_INCLUDED__
#define __ICONV_HH_INCLUDED__
2022-02-26 00:56:46 +00:00
#include <QTextCodec>
#include "wstring.hh"
#include "ex.hh"
/// A wrapper for the iconv() character set conversion functions
class Iconv
{
2022-02-26 00:56:46 +00:00
//iconv_t state;
QTextCodec* codec;
public:
DEF_EX( Ex, "Iconv exception", std::exception )
// Some predefined character sets' names
static char const * const GdWchar;
static char const * const Utf16Le;
static char const * const Utf8;
2022-02-26 00:56:46 +00:00
Iconv( char const * to, char const * from );
2022-02-26 00:56:46 +00:00
~Iconv();
2022-02-26 00:56:46 +00:00
QString convert(void const* & inBuf, size_t& inBytesLeft);
// Converts a given block of data from the given encoding to a wide string.
static gd::wstring toWstring( char const * fromEncoding, void const * fromData,
2022-02-26 00:56:46 +00:00
size_t dataSize );
// Converts a given block of data from the given encoding to an utf8-encoded
// string.
static std::string toUtf8( char const * fromEncoding, void const * fromData,
2022-02-26 00:56:46 +00:00
size_t dataSize );
private:
// Copying/assigning not supported
Iconv( Iconv const & );
Iconv & operator = ( Iconv const & );
};
#endif