I solved the problem with this code:
BROUGHT TO THE BEST VERSION: (I just do not want to convert Latin characters to Unicode, because it will consume additional space without and advantages for my problem (I want to remind you that I want to generate Unicode RTF)).
int main(int argc, char *argv[]) { QApplication app(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QString str(QWidget::tr("Բարև (1-2+3/15,69_) Hello {} [2.63] ")); QString strNew; QString isAcsii; QString tmp; foreach(QChar cr, str) { if(cr.toAscii() != QChar(0)) { isAcsii = static_cast<QString>(cr.toAscii()); strNew+=isAcsii; } else { tmp.setNum(cr.unicode()); tmp.prepend("\\u"); strNew+=tmp; } } QMessageBox::about(0,"Unicode escapes!",strNew); return app.exec(); }
Thanks to @Daniel Earwicker for the algorithm and of course +1.
By the way, you need to specify UTF-8 to encode a text editor.
source share