I try to call an OLE object with parameters - Russian characters, but as a result I get a bad encoding at the output (the OLE driver logs requests). Supported encoding Windows-1251 and UTF-8, but can't send text correctly. I do this:
setlocale(LC_ALL, "Russian");
QString fileToPrint = (qApp->applicationDirPath()+"/"+"test.txt";
QFile filePrt(fileToPrint);
QTextStream inPrt(& filePrt);
inPrt.setCodec("Windows-1251");
if(!filePrt.open(QFile::ReadOnly | QFile::Text))
{
qDebug() << "File failed to open";
return;
}
QStringList toPrint = inPrt.readAll().trimmed().split("\n");
QByteArray strEncSend;
strEncSend+=toPrint [i].replace("\f", "");
object.dynamicCall("FreeTextLine(\""+strEncSend+"\")");
but in logs I get:
02.11.2021 12:25:17.87|Debug|вызов отработан: FreeTextLine("???°?????µ?»?°?", None) = Success
I also tried it through:
QTextCodec *codec = QTextCodec::codecForName("windows-1251");
QByteArray strEnc = codec->fromUnicode(toPrint [i].replace("\f", ""));
Please help, how to set the encoding correctly? Thanks!