3 * \file qstring_helpers.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef QSTRING_HELPERS_H
13 #define QSTRING_HELPERS_H
15 #include "support/strfwd.h"
22 * toqstr - convert a UTF8 encoded char * into a QString
24 * This should not be used, since all possibly non-ASCII stuff should be
25 * stored in a docstring.
27 QString toqstr(char const * str);
31 * toqstr - convert a UTF8 encoded std::string into a QString
33 * This should not be used, since all possibly non-ASCII stuff should be
34 * stored in a docstring.
36 QString toqstr(std::string const & str);
39 /// Is \p c a valid utf16 char?
40 inline bool is_utf16(unsigned int c)
42 // 0xd800 ... 0xdfff is the range of surrogate pairs.
43 return c < 0xd800 || (c > 0xdfff && c < 0x10000);
48 * toqstr - convert a UCS4 encoded docstring into a QString
50 * This is the preferred method of converting anything that possibly
51 * contains non-ASCII stuff to QString.
53 QString toqstr(docstring const & ucs4);
56 * toqstr - convert a UCS4 encoded character into a QString
58 * This is the preferred method of converting anything that possibly
59 * contains non-ASCII stuff to QString.
61 QString toqstr(char_type ucs4);
64 * qstring_to_ucs4 - convert a QString into a UCS4 encoded docstring
66 * This is the preferred method of converting anything that possibly
67 * contains non-ASCII stuff to docstring.
69 docstring qstring_to_ucs4(QString const & qstr);
72 * fromqstr - convert a QString into a UTF8 encoded std::string
74 * This should not be used except for output to lyxerr, since all possibly
75 * non-ASCII stuff should be stored in a docstring.
77 std::string fromqstr(QString const & str);
81 #endif // QSTRING_HELPERS_H