ActiveQT problem with the transfer Russian characters!!!
-
is up
-
Hi,
Clearly It has something to do with encoding...
try this:@QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));
querySubObject(QString("ПользователиИнформационнойБазы").toAscii());@
-
main.cpp UTF-8
@#include <QCoreApplication>
#include <oleauto.h>
#include <ActiveQt/QAxObject>
#include <QAxBase>
#include <QDebug>
#include <QTextCodec>
#include <QString>
#include <QByteArray>
#include <iostream>int main(int argc, char *argv[])
{
::OleInitialize(0);
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));QAxObject * ax = new QAxObject("V82.COMConnector"); QAxObject * ac = ax->querySubObject("Connect(\"Srvr=\"172.0.0.100\";Ref=\"base1\";Usr=\"1C-Bot\";Pwd=\"56q\";\")"); QAxObject * ab = ac->querySubObject(QString("ПользователиИнформационнойБазы").toAscii()); delete ax; qDebug() << "end"; //return a.exec();
}@
Result
@QAxBase::dynamicCallHelper: ¦юы№чютрЄхыш??эЇюЁьрЎшюээющ+рчv: No such property in
[unknown]
Candidates are:
end@main.cpp Windows-1251
Result
@QAxBase::dynamicCallHelper: ??????????????????????????????: No such property in
[unknown]
Candidates are:
end@If you use the English names (NOTE: always use English names will not work, because there are methods and objects in Russian)
main.cpp Windows-1251
@
QAxObject * ab = ac->querySubObject(QString("InfoBaseUsers").toAscii());@Result
@end@ -
Try this:
@QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));
querySubObject(QString::fromWCharArray(L"ПользователиИнформационнойБазы").toUtf8());@
on my system this prints the correct symbols to qDebug() :
@QAxBase::dynamicCallHelper: ПользователиИнформационнойБазы: No such property in {419FEC50-AB6C-49EB-A315-F49E5F804E8D} [unknown]
Candidates are:@but in case this won't work you can also try this:
@QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));querySubObject(QString::fromWCharArray(L"ПользователиИнформационнойБазы").toAscii());@
EDIT1:
By the way, assuming that you work in MSVC2010, if you get some LINK error complaining about QString::fromWCharArray go to your Project properties > C/C++ > Language > Treat wchar_t as Built-in Type set to false -
@
#include <QCoreApplication>
#include <oleauto.h>
#include <ActiveQt/QAxObject>
#include <QAxBase>
#include <QDebug>
#include <QTextCodec>
#include <QString>
#include <QByteArray>
#include <iostream>int main(int argc, char *argv[])
{
::OleInitialize(0);
setlocale(LC_ALL, "Russian");QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));
qDebug() << QString::fromWCharArray(L"ПользователиИнформационнойБазы").toAscii();QAxObject * ax = new QAxObject("V82.COMConnector"); QAxObject * ac = ax->querySubObject("Connect(\"Srvr=\"172.0.0.100\";Ref=\"base1\";Usr=\"1C-Bot\";Pwd=\"56q\";\")"); QAxObject * ab = ac->querySubObject(QString::fromWCharArray(L"ПользователиИнформационнойБазы").toAscii()); delete ax; qDebug() << "end";
}
@Result
@"ПользователиИнформационнойБазы"
QAxBase::dynamicCallHelper: ??????????????????????????????: No such property in
[unknown]
Candidates are:
end@ -
Using pure Qt 4.8.5
Well you guessed thought about MS VS2010. I will think how to tie the Qt libraries to VS2010.Не знаю на сколько правильно мысль перевел translate.google.ru, на всякий случай по русски напишу :)
Использую чистый Qt 4.8.5
Хорошу вы мысль предположили насчёт MS VS2010. Буду думать, как библиотеки Qt прикрутить к VS2010. -
--
--
Did this one:
@QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));querySubObject(QString::fromWCharArray(L"ПользователиИнформационнойБазы").toUtf8());@
also not work?
Тоесть я так понимаю ты сейчас в QtCreator'е сидишь? Думаю большой разницы не будет если в MSVC2010 переешь. Просто удобней если ты к студии привык.
Попробуй как я выше написал, если еще не пробовал, может прокатит наконецтаки )Только тут как-бы по русски нельзя - начнут замечания делать :)
-
Ок, будем по инглишу через гугл транслейтер ...
tried and toUtf8 () and toAscii () does not work ...
I think that the problem is not in the coding and in the transformation, and in QAxBase class. For example, if the above view, it is displayed as correct as qDebug, and the interface itself is not true querySubObject takes. I tried to adjust the encoding to std::cout correctly deduced, and then tried to give ActiveX, did not work ... It's a shame that with all the fine words in English and Russian with error ... :(
As a fan of free software just sit under the Qt :) -
I want to help :( ...
-
Russian discussion is here:
http://forum.vingrad.ru/index.php?show_type=forum&showtopic=370551&kw=кодировка-ошибка -
I created the theme. There are solutions to this problem is not found, so I created a thread in the forum Qt.
-
up top my question
-
is up up
-
anybody here?
-
[quote author="_KUL" date="1383200349"]anybody here?[/quote]
Возможно ответ будет уже не актуален, но все же.
QString::toLocal8Bit() пробовали?
Еще (как вариант) можно перебрать различные кодировки (которые потенциально могут использоваться). Некий брутфорс. Я бы сделал это так: создал текстовый файл в одну строку ("ПользователиИнформационнойБазы"), потом считывал бы содержимое в QByteArray и передавал в querySubObject. Изменение кодировки выполняется например с помощью Notepad++.