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/strfwd.h"
26 IconvProcessor(char const * tocode = "", char const * fromcode = "");
27 /// copy constructor needed because of pimpl_
28 IconvProcessor(IconvProcessor const &);
29 /// assignment operator needed because of pimpl_
30 void operator=(IconvProcessor const &);
34 /// convert any data from \c fromcode to \c tocode unicode format.
35 /// \return the number of bytes of the converted output buffer.
36 int convert(char const * in_buffer, size_t in_size,
37 char * out_buffer, size_t max_out_size);
41 /// \return true if the processor is ready to use.
48 // A single codepoint conversion for utf8_to_ucs4 does not make
49 // sense, so that function is left out.
51 std::vector<char_type> utf8_to_ucs4(std::vector<char> const & utf8str);
53 std::vector<char_type> utf8_to_ucs4(char const * utf8str, size_t ls);
57 std::vector<char_type> utf16_to_ucs4(unsigned short const * s, size_t ls);
61 std::vector<unsigned short> ucs4_to_utf16(char_type const * s, size_t ls);
65 std::vector<char> ucs4_to_utf8(char_type c);
67 std::vector<char> ucs4_to_utf8(std::vector<char_type> const & ucs4str);
69 std::vector<char> ucs4_to_utf8(char_type const * ucs4str, size_t ls);
71 /// convert \p s from encoding \p encoding to ucs4.
72 /// \p encoding must be a valid iconv 8bit encoding
73 std::vector<char_type>
74 eightbit_to_ucs4(char const * s, size_t ls, std::string const & encoding);
76 /// convert \p s from ucs4 to encoding \p encoding.
77 /// \p encoding must be a valid iconv 8bit encoding
78 std::vector<char> ucs4_to_eightbit(char_type const * ucs4str,
79 size_t ls, std::string const & encoding);
81 /// convert ucs4 character \p c to encoding \p encoding.
82 /// \p encoding must be a valid iconv 8bit encoding
83 char ucs4_to_eightbit(char_type c, std::string const & encoding);
86 void ucs4_to_multibytes(char_type ucs4, std::vector<char> & out,
87 std::string const & encoding);
89 extern char const * ucs4_codeset;