Set encoding for process output issue
Solved
General and Desktop
-
wrote on 11 Aug 2017, 08:42 last edited by
-
wrote on 11 Aug 2017, 08:58 last edited by
-
wrote on 11 Aug 2017, 09:03 last edited by
Qt Provides Base64 encoding,
-
Qt Provides Base64 encoding,
wrote on 11 Aug 2017, 09:20 last edited byThanks but
Base64
encoding doesn't work in my case. -
wrote on 11 Aug 2017, 09:25 last edited by
@Cobra91151 ,
Can you show the sample code? -
wrote on 11 Aug 2017, 09:26 last edited by Cobra91151 8 Nov 2017, 09:27
I have tried
setCodec
towindows-1251
,utf-8
,cp1251
,utf-16
but the same result:void Test1::getData(QByteArray data) { QTextStream encodeStream(data); encodeStream.setCodec("windows-1251"); dataTextBrowser->append(encodeStream.readAll()); emit dataFinished(); }
-
wrote on 11 Aug 2017, 09:33 last edited by Cobra91151 8 Nov 2017, 09:39
Here is how in
C#
I have done it:private void myCMDEncoding() { if (CultureInfo.CurrentUICulture.Name == "en-US") { myCMDProcess.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(437); } if (CultureInfo.CurrentCulture.Name == "ru-RU") { myCMDProcess.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(866); } if (CultureInfo.CurrentCulture.Name == "uk-UA") { myCMDProcess.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(866); } }
But now I need it for
C++
inQt
. -
wrote on 11 Aug 2017, 14:50 last edited by
I have fixed it by setting
setCodec
toIBM 866
and now it's working. Also, I included the code here, so others can find the solution.void Test1::getData(QByteArray data) { QTextStream encodeStream(data); encodeStream.setCodec("IBM 866"); dataTextBrowser->append(encodeStream.readAll()); emit dataFinished(); }
1/8