Got off the encoding
-
-
I try use all QString::from*, but it is donr work
bq. What kind of text does the process output?
I think, that it is must output russian text, as think Vass
bq. Ruzik try toLocal8bit() to local QString, after it try using QTextCodec class for correct encoding
I try do it, but i get other strange simbols instead of normal signs:
@ QString str;
QByteArray bArray = process->readAllStandardOutput();
str = QString(bArray).toLocal8Bit();
QTextCodec * tc = QTextCodec::codecForLocale();
if(tc->canEncode(str))
textEdit->append(tc->toUnicode(bArray));@ -
[quote]
@ QString str;
QByteArray bArray = process->readAllStandardOutput();
str = QString(bArray).toLocal8Bit();
QTextCodec * tc = QTextCodec::codecForLocale();
if(tc->canEncode(str))
textEdit->append(tc->toUnicode(bArray));@
[/quote]
You are worried about the outgoing encoding, but you forget the incoming encoding. This code makes no sense at all.Get your incoming encoding right:
@ // untested
QTextCodec *codec = QTextCodec::codecForLocale();
QByteArray bytes = process->readAllStandardOutput();
QString str = codec->toUnicode(bytes);
textEdit->append(str);
@While you're at it, check if codecForLocale() is actually the codec you need.
-
bq. While you’re at it, check if codecForLocale() is actually the codec you need.
It seems that no,
“бв ®ўЄ бўп§Ё б CORBINA...
Џа®ўҐаЄ Ё¬ҐЁ Ё Ї а®«п Ї®«м§®ў ⥫п...
ђҐЈЁбва жЁп Є®¬ЇмовҐа ў бҐвЁ...
“бв ®ў«Ґ бўп§м б CORBINA.
Љ®¬ ¤ гбЇҐи® § ўҐаиҐ . -
That of course implied that you find out what encoding the external process uses to output it's text. Does it look OK when you run the application in a console? Does the application documentation say anything about it?
-
Process - rasdial.exe in Windows(http://msdn.microsoft.com/en-us/library/aa377004(v=vs.85).aspx )
Output on the russian language(on the my computer), but i dont know encoding of this process -
There is a slight possibility that that program outputs utf16 encoded data. Just using the byte array won't bu sufficient then. I'm not sure how to find out whether it does, though.
-
bq. I’m not sure how to find out whether it does, though
I try to ask it by Microsoft))
-
Microsoft didnt get me answer, i think that Vass was right, it is CP1251(Windows-1251)
-
I found that it is may CP1251 or koi8-U
-
Consider choosing that locale explicitly:
@QTextCodec *cp1251 = QTextCodec::codecForName("Windows-1251");
QTextCodec *koi8u = QTextCodec::codecForName("KOI8-U");
@
for example, and see if that makes a difference in converting the string to unicode/QString. -
Yes, it makes a difference in converting the string to unicode/QString
Windows-1251:
“бв ®ў«Ґ бўп§м б CORBINA.
Љ®¬ ¤ гбЇҐи® § ўҐаиҐ .Koi8-U
⌠АБ═ґ╝╒╚╔ґ═ А╒ОїЛ А CORBINA.
┼╝╛═ґє═ ЦА╞╔Хґ╝ ї═╒╔ЮХ╔ґ═. -
I find it, it was CP866
Many thanks for your help!