// we do not want control or space characters
if (cat == QChar::Other_Control || cat == QChar::Separator_Space)
continue;
- QListWidgetItem * lwi = new QListWidgetItem(
- QString::fromUcs4((uint const *) &c, 1));
+ QListWidgetItem * lwi = new QListWidgetItem(toqstr(c));
if (show_all || c >= range_start && c <= range_end) {
lwi->setTextAlignment(Qt::AlignCenter);
symbolsLW->addItem(lwi);
return QString::fromUcs4(reinterpret_cast<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)
+{
+ return QString::fromUcs4(reinterpret_cast<uint const *>(&ucs4), 1);
+}
/**
* qstring_to_ucs4 - convert a QString into a UCS4 encoded docstring