Tue, 29 Apr 2014 00:00:45 +0300
- use a function for utf16 type conversion instead of a macro
src/configDialog.cc | file | annotate | diff | comparison | revisions | |
src/macros.h | file | annotate | diff | comparison | revisions | |
src/miscallenous.h | file | annotate | diff | comparison | revisions |
--- a/src/configDialog.cc Mon Apr 28 21:31:24 2014 +0300 +++ b/src/configDialog.cc Tue Apr 29 00:00:45 2014 +0300 @@ -241,7 +241,7 @@ dsb_gridData[i][0]->setValue (*g_gridInfo[i].coordsnap); dsb_gridData[i][1]->setValue (*g_gridInfo[i].anglesnap); dsb_gridData[i][1]->setMaximum (360); - dsb_gridData[i][1]->setSuffix (UTF16 (u"\u00B0")); // degree symbol + dsb_gridData[i][1]->setSuffix (utf16 (u"\u00B0")); // degree symbol } ui->grids->setLayout (gridlayout);
--- a/src/macros.h Mon Apr 28 21:31:24 2014 +0300 +++ b/src/macros.h Tue Apr 29 00:00:45 2014 +0300 @@ -64,8 +64,6 @@ // #define elif(A) else if (A) -#define UTF16(A) (QString::fromUtf16 (reinterpret_cast<const ushort*> (A))) - // ============================================================================= // #ifdef WIN32
--- a/src/miscallenous.h Mon Apr 28 21:31:24 2014 +0300 +++ b/src/miscallenous.h Tue Apr 29 00:00:45 2014 +0300 @@ -142,3 +142,17 @@ std::sort (a.begin(), a.end()); a.erase (std::unique (a.begin(), a.end()), a.end()); } + +inline String utf16 (const char16_t* a) +{ + if (Q_LIKELY (sizeof(char16_t) == sizeof(unsigned short))) + return String::fromUtf16 (reinterpret_cast<const unsigned short*> (a)); + + QVector<unsigned short> data; + + for (const char16_t* ap = &a[0]; *ap != '\u0000'; ++ap) + data << *ap; + + data << '\u0000'; + return String::fromUtf16 (data.constData()); +}