Peter Kümmel wrote:
Abdelrazak Younes wrote:
Maybe it is worth to define a inline function in qt_helpers:
QChar const & ucs4_to_QChar(char_type c)
Yes but without the ref, see my newer patch.
Index: frontends/qt4/QLyXKeySym.C
===================================================================
--- frontends/qt4/QLyXKeySym.C (revision 14842)
+++ frontends/qt4/QLyXKeySym.C (working copy)
@@ -200,18 +200,22 @@
size_t QLyXKeySym::getUCSEncoded() const
{
should the return type not be a char_type?
IMHO yes but this is Lars code and I am going to touch that until he
voices his opinion.
- unsigned short const * ptr = text_.utf16();
- std::vector<unsigned short> tmp(ptr, ptr + text_.length());
+ // FIXME: Why do we need more than one char?
+ //BOOST_ASSERT(text_.size() == 1);
+ //return static_cast<boost::uint32_t>(text_[0].unicode());
- //lyxerr << "Data is " << tmp << endl;
- lyxerr << "Length is " << text_.length() << endl;
+ //static char_type * ucs4 = new char_type[1000];
+ char_type ucs4[4];
Why do you need 4 char_types for one character?
I needed something greater than 1. I settled to 4 arbitrarily.
Only ucs4[0] is returned.
Yes, see my newer patch. I was afraid that there could be more than one
char in the QKeyEvent but apparently not.
+#define ENDIAN_OFFSET 0
+
+ char const * ptr = reinterpret_cast<char const *>(str);
+ char const * end_ptr = ptr + 4*ls;
+ for (; ptr < end_ptr; ptr += 4)
+ s.append(QChar(*(reinterpret_cast<unsigned short const *>(ptr +
ENDIAN_OFFSET))));
+
+ return s;
+}
+
+
Could the code not been switched by a macro?
Yes or a "#ifdef LITTLE_ENDIAN #else...", if something like that exists.
Maybe Qt has some global defines we could use.
Abdel.