3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
10 * A collection of unicode conversion functions, using iconv.
13 #ifndef LYX_SUPPORT_UNICODE_H
14 #define LYX_SUPPORT_UNICODE_H
16 #include "support/types.h"
18 #include <boost/scoped_ptr.hpp>
30 char const * tocode = "",
31 char const * fromcode = "");
32 /// copy constructor needed because of pimpl_
33 IconvProcessor(IconvProcessor const &);
34 /// assignment operator needed because of pimpl_
35 IconvProcessor & operator=(IconvProcessor const &);
36 /// destructor (needs to be implemented in the .C file because the
37 /// boost::scoped_ptr destructor needs a fully defined type
40 /// convert any data from \c fromcode to \c tocode unicode format.
41 /// \return the number of bytes of the converted output buffer.
43 char const * in_buffer,
49 /// \return true if the processor is ready to use.
53 std::string fromcode_;
56 boost::scoped_ptr<Private> pimpl_;
59 /// This is implemented in lyx_main.C for the LyX program
60 /// and in client.C for the LyX client program.
61 extern IconvProcessor & utf8ToUcs4();
63 // A single codepoint conversion for utf8_to_ucs4 does not make
64 // sense, so that function is left out.
66 std::vector<lyx::char_type> utf8_to_ucs4(std::vector<char> const & utf8str);
68 std::vector<lyx::char_type> utf8_to_ucs4(char const * utf8str, size_t ls);
72 std::vector<char_type> utf16_to_ucs4(unsigned short const * s, size_t ls);
76 std::vector<unsigned short> ucs4_to_utf16(char_type const * s, size_t ls);
80 std::vector<char> ucs4_to_utf8(lyx::char_type c);
82 std::vector<char> ucs4_to_utf8(std::vector<lyx::char_type> const & ucs4str);
84 std::vector<char> ucs4_to_utf8(lyx::char_type const * ucs4str, size_t ls);
86 /// convert \p s from encoding \p encoding to ucs4.
87 /// \p encoding must be a valid iconv 8bit encoding
88 std::vector<lyx::char_type>
89 eightbit_to_ucs4(char const * s, size_t ls, std::string const & encoding);
91 /// convert \p s from ucs4 to encoding \p encoding.
92 /// \p encoding must be a valid iconv 8bit encoding
94 ucs4_to_eightbit(lyx::char_type const * ucs4str, size_t ls, std::string const & encoding);
96 extern char const * ucs4_codeset;