QString my_string = QString::fromUtf8("бла-бла-бла");
QString str="\n___ĄČĖĘŠŪŽąčėęšūųž___\n";
QString str=QString::fromUtf8("\n___ĄČĖĘŠŪŽąčėęšūųž___\n")
#include <QtGui>#include <QTextCodec>int main(int argc, char *argv[]){ QApplication a(argc, argv); QTextCodec *codec=QTextCodec::codecForName("utf8"); QTextCodec::setCodecForCStrings(codec); QTextCodec::setCodecForTr(codec); QString str="\n___ĄČĖĘŠŪŽąčėęšūųž___\n"; QString strHtml="<html><head>" "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">" "</head><body>"+str+"</body></html>"; QLabel lbl; lbl.setText(str); lbl.show(); QTextStream stream; QFile infile("try.html"); if(!infile.open(QIODevice::WriteOnly)) QMessageBox::warning(0,"Error","Can't open file",QMessageBox::Ok); else { stream.setDevice(&infile); stream<<strHtml; infile.close(); if(stream.status()!=QTextStream::Ok) QMessageBox::warning(0,"Error","Can't write to file",QMessageBox::Ok); } return a.exec();}
C++ (Qt)QString str("Bezier"); // слово в котором у меня были проблемы с первой "е"qDebug() << str; // убедимся это отображается как надоprintf("str[1] = 0x%x\n", (int) str[1].unicode()); // нужный код
QTextStream stream; QFile infile("try.html"); if(!infile.open(QIODevice::WriteOnly)) QMessageBox::warning(0,"Error","Can't open file",QMessageBox::Ok); else { stream.setDevice(&infile); stream<<strHtml; infile.close(); if(stream.status()!=QTextStream::Ok) QMessageBox::warning(0,"Error","Can't write to file",QMessageBox::Ok); }