EBOOKCharsetConverter.h Source File documentation

EBOOKCharsetConverter.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/*
3 * This file is part of the libe-book project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef EBOOKCHARSETCONVERTER_H_INCLUDED
11#define EBOOKCHARSETCONVERTER_H_INCLUDED
12
13#include <memory>
14#include <vector>
15
16#include <unicode/ucnv.h>
17
18namespace libebook
19{
20
21 class EBOOKCharsetConverter
22{
23 // disable copying
24 EBOOKCharsetConverter(const EBOOKCharsetConverter &other);
25 EBOOKCharsetConverter &operator=(const EBOOKCharsetConverter &other);
26
27public:
28 explicit EBOOKCharsetConverter(const char *encoding = nullptr);
29 ~EBOOKCharsetConverter();
30
31 bool guessEncoding(const char *in, unsigned length);
32
33 bool convertBytes(const char *in, unsigned length, std::vector<char> &out);
34
35private:
36 using UConverterPtr_t = std::unique_ptr<UConverter, void (*)(UConverter *)>;
37 UConverterPtr_t m_converterToUnicode;
38 UConverterPtr_t m_converterToUTF8;
39};
40
41}
42
43#endif // EBOOKCHARSETCONVERTER_H_INCLUDED
44
45/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libebook::EBOOKCharsetConverter::operator=
EBOOKCharsetConverter & operator=(const EBOOKCharsetConverter &other)
libebook::EBOOKCharsetConverter::m_converterToUnicode
UConverterPtr_t m_converterToUnicode
Definition EBOOKCharsetConverter.h:37
libebook::EBOOKCharsetConverter::EBOOKCharsetConverter
EBOOKCharsetConverter(const EBOOKCharsetConverter &other)
libebook::EBOOKCharsetConverter::convertBytes
bool convertBytes(const char *in, unsigned length, std::vector< char > &out)
Definition EBOOKCharsetConverter.cpp:109
libebook::EBOOKCharsetConverter::~EBOOKCharsetConverter
~EBOOKCharsetConverter()
Definition EBOOKCharsetConverter.cpp:87
libebook::EBOOKCharsetConverter::guessEncoding
bool guessEncoding(const char *in, unsigned length)
Definition EBOOKCharsetConverter.cpp:91
libebook::EBOOKCharsetConverter::UConverterPtr_t
std::unique_ptr< UConverter, void(*)(UConverter *)> UConverterPtr_t
Definition EBOOKCharsetConverter.h:36
libebook::EBOOKCharsetConverter::m_converterToUTF8
UConverterPtr_t m_converterToUTF8
Definition EBOOKCharsetConverter.h:38
libebook
Definition BBeBCollector.cpp:20