libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
Ansi.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef ANSI_H_
32 #define ANSI_H_
33 
34 #include <string.h>
35 #include <string>
36 #include <map>
37 #include <vector>
38 
39 namespace BaseLib
40 {
41 class Ansi
42 {
43 public:
44  Ansi(bool ansiToUtf8, bool utf8ToAnsi);
45  virtual ~Ansi() {}
46 
47  std::string toUtf8(const std::string& ansiString);
48  std::string toUtf8(const char* ansiString, uint32_t length);
49  std::string toAnsi(const std::string& utf8String);
50  std::string toAnsi(const char* utf8String, uint32_t length);
51 protected:
52  bool _ansiToUtf8 = false;
53  bool _utf8ToAnsi = false;
54 
55  std::vector<std::vector<uint8_t>> _utf8Lookup;
56  std::map<uint32_t, uint8_t> _ansiLookup;
57 };
58 }
59 #endif
std::map< uint32_t, uint8_t > _ansiLookup
Definition: Ansi.h:56
std::vector< std::vector< uint8_t > > _utf8Lookup
Definition: Ansi.h:55
bool _ansiToUtf8
Definition: Ansi.h:52
Definition: Ansi.h:41
Definition: BaseLib.cpp:34
virtual ~Ansi()
Definition: Ansi.h:45
Ansi(bool ansiToUtf8, bool utf8ToAnsi)
Definition: Ansi.cpp:36
std::string toUtf8(const std::string &ansiString)
Definition: Ansi.cpp:132
std::string toAnsi(const std::string &utf8String)
Definition: Ansi.cpp:179
bool _utf8ToAnsi
Definition: Ansi.h:53