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"
23 LyXErr & operator<<(LyXErr &, QString const &);
26 * toqstr - convert a UTF8 encoded char * into a QString
28 * This should not be used, since all possibly non-ASCII stuff should be
29 * stored in a docstring.
31 QString toqstr(char const * str);
35 * toqstr - convert a UTF8 encoded std::string into a QString
37 * This should not be used, since all possibly non-ASCII stuff should be
38 * stored in a docstring.
40 QString toqstr(std::string const & str);
43 /// Is \p c a valid utf16 char?
44 inline bool is_utf16(char_type c)
46 // 0xd800 ... 0xdfff is the range of surrogate pairs.
47 return c < 0xd800 || (c > 0xdfff && c < 0x10000);
52 * toqstr - convert a UCS4 encoded docstring into a QString
54 * This is the preferred method of converting anything that possibly
55 * contains non-ASCII stuff to QString.
57 QString toqstr(docstring const & ucs4);
60 * toqstr - convert a UCS4 encoded character into a QString
62 * This is the preferred method of converting anything that possibly
63 * contains non-ASCII stuff to QString.
65 QString toqstr(char_type ucs4);
68 * qstring_to_ucs4 - convert a QString into a UCS4 encoded docstring
70 * This is the preferred method of converting anything that possibly
71 * contains non-ASCII stuff to docstring.
73 docstring qstring_to_ucs4(QString const & qstr);
76 * fromqstr - convert a QString into a UTF8 encoded std::string
78 * This should not be used except for output to lyxerr, since all possibly
79 * non-ASCII stuff should be stored in a docstring.
81 std::string fromqstr(QString const & str);
84 * constructs a regex to filter on consecutive characters
85 * matches lower- and uppercase on lowercase characters,
86 * and just uppercase for uppercase
88 QString charFilterRegExp(QString const & filter);
91 * as above, but constructs a capturing regex for a sequence of characters
93 QString charFilterRegExpC(QString const & filter);
97 #endif // QSTRING_HELPERS_H