Pyrogenesis  trunk
iconv.hpp
Go to the documentation of this file.
1 // tinygettext - A gettext replacement that works directly on .po files
2 // Copyright (c) 2006 Ingo Ruhnke <grumbel@gmail.com>
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 //
8 // Permission is granted to anyone to use this software for any purpose,
9 // including commercial applications, and to alter it and redistribute it
10 // freely, subject to the following restrictions:
11 //
12 // 1. The origin of this software must not be misrepresented; you must not
13 // claim that you wrote the original software. If you use this software
14 // in a product, an acknowledgement in the product documentation would be
15 // appreciated but is not required.
16 // 2. Altered source versions must be plainly marked as such, and must not be
17 // misrepresented as being the original software.
18 // 3. This notice may not be removed or altered from any source distribution.
19 
20 #ifndef HEADER_TINYGETTEXT_ICONV_HPP
21 #define HEADER_TINYGETTEXT_ICONV_HPP
22 
23 #include <string>
24 
25 #ifdef HAVE_SDL
26 # include "SDL.h"
27 
28 # define tinygettext_ICONV_CONST const
29 # define tinygettext_iconv_t SDL_iconv_t
30 # define tinygettext_iconv SDL_iconv
31 # define tinygettext_iconv_open SDL_iconv_open
32 # define tinygettext_iconv_close SDL_iconv_close
33 #else
34 # include <iconv.h>
35 
36 # ifdef HAVE_ICONV_CONST
37 # define tinygettext_ICONV_CONST ICONV_CONST
38 # else
39 # define tinygettext_ICONV_CONST
40 # endif
41 
42 # define tinygettext_iconv_t iconv_t
43 # define tinygettext_iconv iconv
44 # define tinygettext_iconv_open iconv_open
45 # define tinygettext_iconv_close iconv_close
46 #endif
47 
48 namespace tinygettext {
49 
50 class IConv
51 {
52 private:
53  std::string to_charset;
54  std::string from_charset;
56 
57 public:
58  IConv();
59  IConv(const std::string& fromcode, const std::string& tocode);
60  ~IConv();
61 
62  void set_charsets(const std::string& fromcode, const std::string& tocode);
63  std::string convert(const std::string& text);
64 
65 private:
66  IConv (const IConv&);
67  IConv& operator= (const IConv&);
68 };
69 
70 } // namespace tinygettext
71 
72 #endif
73 
74 /* EOF */
Definition: iconv.hpp:50
IConv & operator=(const IConv &)
std::string from_charset
Definition: iconv.hpp:54
std::string convert(const std::string &text)
Convert a string from encoding to another.
Definition: iconv.cpp:102
IConv()
Definition: iconv.cpp:39
void set_charsets(const std::string &fromcode, const std::string &tocode)
Definition: iconv.cpp:60
#define tinygettext_iconv_t
Definition: iconv.hpp:42
Definition: dictionary.hpp:29
std::string to_charset
Definition: iconv.hpp:53
~IConv()
Definition: iconv.cpp:53
tinygettext_iconv_t cd
Definition: iconv.hpp:55