標準出力に疑似ローカライズ (Unicode) 文字列を出力するコンソール アプリ (myApp.exe) を実行しています。これを通常のコマンド プロンプト (cmd.exe) で実行すると、Unicode データが失われます。これを Unicode コマンド プロンプト (cmd.exe /u) で実行するか、コンソールのプロパティを「Lucida Console」に設定すると、Unicode 文字列が維持されます。
このアプリを C# で実行し、Unicode 文字列をローカル変数にリダイレクトしたいと思います。RedirectStandardOutput = true で Process オブジェクトを使用していますが、Unicode 文字列は常に失われます。
この Unicode 情報を保持するように指定するにはどうすればよいですか?
private static int RunDISM(string Args, out string ConsoleOutput)
{
Process process = new Process();
process.StartInfo.FileName = "myApp.exe";
process.StartInfo.Arguments = Args;
try
{
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
process.Start();
process.WaitForExit(Int32.MaxValue);
}
catch (Exception e)
{
WEX.Logging.Interop.Log.Assert("Failure while starting or running process.\nERROR: " + e.Message);
ConsoleOutput = null;
return EXITCODE_ERROR;
}
ConsoleOutput = process.StandardOutput.ReadToEnd();
return process.ExitCode;
}