Solved Set encoding for process output issue
-
Hi! I want to set encoding for cmd process for russian ouput. In
C#
theProcess
hasStandardOutputEncoding
function, inQt
such function does not exists.Here is the problem:
Any suggestion how to accomplish it?
-
-
Qt Provides Base64 encoding,
-
Thanks but
Base64
encoding doesn't work in my case. -
@Cobra91151 ,
Can you show the sample code? -
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(); }
-
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
.Console output:
-
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(); }