]> git.lyx.org Git - lyx.git/blob - src/support/qstring_helpers.h
Fix text direction issue for InsetInfo in RTL context
[lyx.git] / src / support / qstring_helpers.h
1 // -*- C++ -*-
2 /**
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.
6  *
7  * \author Dekel Tsur
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef QSTRING_HELPERS_H
13 #define QSTRING_HELPERS_H
14
15 #include "support/strfwd.h"
16
17 class QString;
18
19 namespace lyx {
20
21 class LyXErr;
22
23 LyXErr & operator<<(LyXErr &, QString const &);
24
25 /**
26  * toqstr - convert a UTF8 encoded char * into a QString
27  *
28  * This should not be used, since all possibly non-ASCII stuff should be
29  * stored in a docstring.
30  */
31 QString toqstr(char const * str);
32
33
34 /**
35  * toqstr - convert a UTF8 encoded std::string into a QString
36  *
37  * This should not be used, since all possibly non-ASCII stuff should be
38  * stored in a docstring.
39  */
40 QString toqstr(std::string const & str);
41
42
43 /// Is \p c a valid utf16 char?
44 inline bool is_utf16(unsigned int c)
45 {
46         // 0xd800 ... 0xdfff is the range of surrogate pairs.
47         return c < 0xd800 || (c > 0xdfff && c < 0x10000);
48 }
49
50
51 /**
52  * toqstr - convert a UCS4 encoded docstring into a QString
53  *
54  * This is the preferred method of converting anything that possibly
55  * contains non-ASCII stuff to QString.
56  */
57 QString toqstr(docstring const & ucs4);
58
59 /**
60  * toqstr - convert a UCS4 encoded character into a QString
61  *
62  * This is the preferred method of converting anything that possibly
63  * contains non-ASCII stuff to QString.
64  */
65 QString toqstr(char_type ucs4);
66
67 /**
68  * qstring_to_ucs4 - convert a QString into a UCS4 encoded docstring
69  *
70  * This is the preferred method of converting anything that possibly
71  * contains non-ASCII stuff to docstring.
72  */
73 docstring qstring_to_ucs4(QString const & qstr);
74
75 /**
76  * fromqstr - convert a QString into a UTF8 encoded std::string
77  *
78  * This should not be used except for output to lyxerr, since all possibly
79  * non-ASCII stuff should be stored in a docstring.
80  */
81 std::string fromqstr(QString const & str);
82
83 } // namespace lyx
84
85 #endif // QSTRING_HELPERS_H