src/miscallenous.h

changeset 755
d2bd4139040c
parent 754
c37564d59ce1
child 757
8ab9fa53142b
equal deleted inserted replaced
754:c37564d59ce1 755:d2bd4139040c
140 template<class T> void removeDuplicates (QList<T>& a) 140 template<class T> void removeDuplicates (QList<T>& a)
141 { 141 {
142 std::sort (a.begin(), a.end()); 142 std::sort (a.begin(), a.end());
143 a.erase (std::unique (a.begin(), a.end()), a.end()); 143 a.erase (std::unique (a.begin(), a.end()), a.end());
144 } 144 }
145
146 inline String utf16 (const char16_t* a)
147 {
148 if (Q_LIKELY (sizeof(char16_t) == sizeof(unsigned short)))
149 return String::fromUtf16 (reinterpret_cast<const unsigned short*> (a));
150
151 QVector<unsigned short> data;
152
153 for (const char16_t* ap = &a[0]; *ap != '\u0000'; ++ap)
154 data << *ap;
155
156 data << '\u0000';
157 return String::fromUtf16 (data.constData());
158 }

mercurial