00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 00002 /* 00003 * This file is part of the libe-book project. 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 00010 #ifndef EBOOKCHARSETCONVERTER_H_INCLUDED 00011 #define EBOOKCHARSETCONVERTER_H_INCLUDED 00012 00013 #include <vector> 00014 00015 #include <unicode/ucnv.h> 00016 00017 namespace libebook 00018 { 00019 00020 class EBOOKCharsetConverter 00021 { 00022 // disable copying 00023 EBOOKCharsetConverter(const EBOOKCharsetConverter &other); 00024 EBOOKCharsetConverter &operator=(const EBOOKCharsetConverter &other); 00025 00026 public: 00027 explicit EBOOKCharsetConverter(const char *encoding = 0); 00028 ~EBOOKCharsetConverter(); 00029 00030 bool guessEncoding(const char *in, unsigned length); 00031 00032 bool convertBytes(const char *in, unsigned length, std::vector<char> &out); 00033 00034 private: 00035 UConverter *m_converterToUnicode; 00036 UConverter *m_converterToUTF8; 00037 }; 00038 00039 } 00040 00041 #endif // EBOOKCHARSETCONVERTER_H_INCLUDED 00042 00043 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */