#include <QCoreApplication>
#include <QFile>
#include <QTextCodec>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
const std::string pattern = u8"АЛГ %1";
const int count = 456;
const auto utf8 = QTextCodec::codecForName("UTF-8");
const auto cp1251 = QTextCodec::codecForName("cp1251");
const auto outText = utf8->toUnicode( QByteArray::fromRawData(pattern.c_str(), pattern.length()) ).arg(count);
QFile socket("out.txt");
socket.open(QFile::WriteOnly | QFile::Truncate);
socket.write(cp1251->fromUnicode(outText));
return 0;
}