]> git.lyx.org Git - lyx.git/blobdiff - src/support/qstring_helpers.h
Replace the text class shared ptr by good old index-into-global-list.
[lyx.git] / src / support / qstring_helpers.h
index 87b77ccd107b5c73d27fadd8c6037695d08aeb3d..39c824fcf378c4dda11e1dd91ab088604fff48c3 100644 (file)
@@ -61,9 +61,20 @@ inline QString const toqstr(docstring const & ucs4)
 {
        // If possible we let qt do the work, since this version does not
        // need to be superfast.
-       return QString::fromUcs4(reinterpret_cast<uint const *>(ucs4.data()), ucs4.length());
+       return QString::fromUcs4((uint const *)ucs4.data(), ucs4.length());
 }
 
+/**
+ * toqstr - convert a UCS4 encoded character into a QString
+ *
+ * This is the preferred method of converting anything that possibly
+ * contains non-ASCII stuff to QString.
+ */
+inline QString const toqstr(char_type ucs4)
+{
+       union { char_type c; uint i; } u = { ucs4 };
+       return QString::fromUcs4(&u.i, 1);
+}
 
 /**
  * qstring_to_ucs4 - convert a QString into a UCS4 encoded docstring