Windows 7 x64, AutoCAD 2013 SP1.1.
This problem are exists in AutoCAD 2013 only (look the screen below). In the AutoCAD 2009-2012 it works fine.
String _args = sb.ToString();
String exeName
= new FileInfo
(Path
.Combine(curDir,
@"..\..\recovery")).FullName; Process proc
= new Process
(); ProcessStartInfo info
= new ProcessStartInfo
(); info.CreateNoWindow = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Int32 codepage = CultureInfo.CurrentCulture.TextInfo.OEMCodePage;
info.StandardOutputEncoding = Encoding.GetEncoding(codepage);
info.FileName = exeName;
info.Arguments = String.Format("{0} -clear", _args);
info
.WorkingDirectory = new DirectoryInfo
(Path
.Combine(curDir,
@"..\..\")).FullName; proc.StartInfo = info;
proc.Start();
String outputText = String.Empty;
#if acad2013
Encoding enc = Encoding.Unicode; // What encoding I must point here?
Int32 b;
List
<Byte> bytes
= new List
<Byte>(); while ((b = proc.StandardOutput.BaseStream.ReadByte()) != -1)
bytes.Add((Byte) b);
Byte[] bytes2 = Encoding.Convert(Encoding.GetEncoding(codepage), enc, bytes.ToArray());
outputText = enc.GetString(bytes2);
#else
outputText = proc.StandardOutput.ReadToEnd();
#endif
if (doc != null) {
if (printMsg) {
doc.Editor.WriteMessage(outputText);
doc.Editor.WriteMessage(Environment.NewLine);
doc.Editor.WriteMessage("Операция завершена."); // Operation is complete (ru-RU)
doc.Editor.WriteMessage(Environment.NewLine);
}
}
In the AutoCAD 2013 the result looks so (look attached screen below)...
I have tried to look all encodings results:
Int32 b;
List
<Byte> bytes
= new List
<Byte>();while ((b = proc.StandardOutput.BaseStream.ReadByte()) != -1)
bytes.Add((Byte) b);
// Look for each encoding...
// I look in parts
Int32 skip = 120; // I have tried the next values: 0, 20, 40, 60, ..., 120
Int32 take = 20;
Int32 count = Encoding.GetEncodings().Length; // 140
foreach (EncodingInfo item in Encoding.GetEncodings().Skip(skip).Take(take)) {
Encoding x = item.GetEncoding();
Byte[] bytes2 = Encoding.Convert(Encoding.GetEncoding(codepage), x, bytes.ToArray());
outputText = x.GetString(bytes2);
if (doc != null) {
if (printMsg) {
doc.Editor.WriteMessage("\nEncoding: {0}, CodePage = {1}\n", x.EncodingName, x.CodePage);
doc.Editor.WriteMessage(outputText);
doc.Editor.WriteMessage(Environment.NewLine);
doc
.Editor.WriteMessage(new String('*',
20)); }
}
}
But I receive incorrect result always.
Where is the problem?