ActiveQT problem with the transfer Russian characters!!!



  • Hello!
    There is a need to connect to the server through 1C "Your text to link here...":http://1c.ru/ atstiveks COM.
    When using English-language queries, there is no problem, but if you use the Russian names of the parameters (1C is a Russian system for financial accounting), an error occurs when calling methods:
    QAxObject :: querySubObject
    QAxBase :: dynamicCallHelper
    Solving this problem using Qt 4.8 (because it has the support of the functions)

    main.cpp UTF-8
    @
    #include <QApplication>
    #include <oleauto.h>
    #include <ActiveQt/QAxObject>
    #include <QAxBase>
    #include <QDebug>
    #include <QTextCodec>
    #include <QString>
    #include <QByteArray>

    int main(int argc, char *argv[])
    {

    QCoreApplication a(argc, argv);
    ::OleInitialize(0);
    
    setlocale(LC_ALL, "Russian");
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    
    qDebug() << "текст2";
    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("ПользователиИнформационнойБазы");
    
    delete ax;
    
    qDebug() << "end";
    return a.exec&#40;&#41;;
    

    }
    @

    Result
    @
    QAxBase::dynamicCallHelper: ПользователиИнформационнойБазы: No such property in
    [unknown]
    Candidates are:
    end
    @

    I read on the forum that the COM server 1C takes CP1251 encoding and returns the result UTF-8.

    main.cpp UTF-8
    @
    #include <QApplication>
    #include <oleauto.h>
    #include <ActiveQt/QAxObject>
    #include <QAxBase>
    #include <QDebug>
    #include <QTextCodec>
    #include <QString>
    #include <QByteArray>

    int main(int argc, char *argv[])
    {

    QCoreApplication a(argc, argv);
    ::OleInitialize(0);
    
    setlocale(LC_ALL, "Russian");
    [B]QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));[/B]
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    
    qDebug() << "текст2";
    QAxObject * ax = new QAxObject("V82.COMConnector");
    QAxObject * ac = ax->querySubObject("Connect(\"Srvr=\"172.0.0.100\";Ref=\"base1\";Usr=\"1C-Bot\";Pwd=\"56q\";\")");
    
    [B]QAxObject * ab = ac->querySubObject(QAxObject::tr("ПользователиИнформационнойБазы").toAscii());[/B]
    
    delete ax;
    
    qDebug() << "end";
    return a.exec&#40;&#41;;
    

    }@

    Result
    @QAxBase::dynamicCallHelper: Р?Р?Р>С?Р·Р?Р?Р°С'РчР>РёР?Р?С"Р?С?Р?Р°С┼РёР?Р?Р?Р?Р№
    Р'азС<: No such property in [unknown]
    Candidates are:
    end@

    Why is this happening?

    If you use Visual Basic 2010
    @Module Module1

    Sub Main(&#41;
        Dim cntr As Object
        Dim trade As Object
        Dim allusers As Object
        Dim users As Object
    
        Dim line As String
    
        cntr = CreateObject("V82.COMConnector")
        trade = cntr.Connect("Srvr=""172.0.0.100"";Ref=""base1"";Usr=""1C-Bot"";Pwd=""56q"";")
        allusers = trade.ПользователиИнформационнойБазы
        users = allusers.НайтиПоИмени("admin")
        Console.WriteLine(users.Имя)
        Console.WriteLine(users.АутентификацияОС)
    
        Console.WriteLine("end")
    
        line = Console.ReadLine()
    
    End Sub
    

    End Module@
    Then everything is working properly! ;(



  • is uppps ...



  • 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&#40;&#41;;
    

    }@

    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 :( ...





  • 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++.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.