00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 00002 /* libe-book 00003 * Version: MPL 2.0 / LGPLv2.1+ 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this 00007 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * Alternatively, the contents of this file may be used under the terms 00010 * of the GNU Lesser General Public License Version 2.1 or later 00011 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are 00012 * applicable instead of those above. 00013 * 00014 * For further information visit http://libebook.sourceforge.net 00015 */ 00016 00017 #ifndef EBOOKCHARSETCONVERTER_H_INCLUDED 00018 #define EBOOKCHARSETCONVERTER_H_INCLUDED 00019 00020 #include <vector> 00021 00022 #include <unicode/ucnv.h> 00023 00024 namespace libebook 00025 { 00026 00027 class EBOOKCharsetConverter 00028 { 00029 // disable copying 00030 EBOOKCharsetConverter(const EBOOKCharsetConverter &other); 00031 EBOOKCharsetConverter &operator=(const EBOOKCharsetConverter &other); 00032 00033 public: 00034 explicit EBOOKCharsetConverter(const char *encoding = 0); 00035 ~EBOOKCharsetConverter(); 00036 00037 bool guessEncoding(const char *in, unsigned length); 00038 00039 bool convertBytes(const char *in, unsigned length, std::vector<char> &out); 00040 00041 private: 00042 UConverter *m_converterToUnicode; 00043 UConverter *m_converterToUTF8; 00044 }; 00045 00046 } 00047 00048 #endif // EBOOKCHARSETCONVERTER_H_INCLUDED 00049 00050 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */