Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2007-07-25 02:26:31 +0400
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2007-07-25 02:26:31 +0400
commitb92f00f9a4e97348adb497b2102f52bfaf766f1d (patch)
treec8cfd99f7ec2a9f7e73d9461e499ade6b1f10fd5 /mcs/class/System/System.Diagnostics/Process.cs
parentb0a3445012b13b00754cad91c1e4c6632cad576c (diff)
2007-07-24 Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
* Process.cs: use the default encoding or the windows input/output encodings for the process input/output/error streams. Bug #80838 fixed. svn path=/trunk/mcs/; revision=82618
Diffstat (limited to 'mcs/class/System/System.Diagnostics/Process.cs')
-rw-r--r--mcs/class/System/System.Diagnostics/Process.cs61
1 files changed, 58 insertions, 3 deletions
diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs
index bb457272e80..a5f79f60b71 100644
--- a/mcs/class/System/System.Diagnostics/Process.cs
+++ b/mcs/class/System/System.Diagnostics/Process.cs
@@ -1009,18 +1009,18 @@ namespace System.Diagnostics {
if (startInfo.RedirectStandardInput == true) {
MonoIO.Close (stdin_rd, out error);
- process.input_stream = new StreamWriter (new FileStream (stdin_wr, FileAccess.Write, true));
+ process.input_stream = new StreamWriter (new FileStream (stdin_wr, FileAccess.Write, true), ConsoleEncoding.InputEncoding);
process.input_stream.AutoFlush = true;
}
if (startInfo.RedirectStandardOutput == true) {
MonoIO.Close (stdout_wr, out error);
- process.output_stream = new StreamReader (new FileStream (process.stdout_rd, FileAccess.Read, true));
+ process.output_stream = new StreamReader (new FileStream (process.stdout_rd, FileAccess.Read, true), ConsoleEncoding.OutputEncoding);
}
if (startInfo.RedirectStandardError == true) {
MonoIO.Close (stderr_wr, out error);
- process.error_stream = new StreamReader (new FileStream (process.stderr_rd, FileAccess.Read, true));
+ process.error_stream = new StreamReader (new FileStream (process.stderr_rd, FileAccess.Read, true), ConsoleEncoding.OutputEncoding);
}
process.StartExitCallbackIfNeeded ();
@@ -1467,6 +1467,61 @@ namespace System.Diagnostics {
// Do nothing, we don't own the handle and we won't close it.
}
}
+
+ class ConsoleEncoding
+ {
+ [DllImport ("kernel32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
+ private static extern int GetConsoleCP ();
+ [DllImport ("kernel32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
+ private static extern int GetConsoleOutputCP ();
+
+ static bool RunningOnWindows {
+ get {
+ return ((int) Environment.OSVersion.Platform != 4 &&
+#if NET_2_0
+ Environment.OSVersion.Platform != PlatformID.Unix);
+#else
+ (int) Environment.OSVersion.Platform != 128);
+#endif
+ }
+ }
+
+ public static Encoding InputEncoding {
+ get {
+ if(!RunningOnWindows) {
+ return Encoding.Default;
+ }
+
+#if !NET_2_0
+ try {
+ return Encoding.GetEncoding (GetConsoleCP ());
+ } catch {
+ return Encoding.GetEncoding (28591);
+ }
+#else
+ return Console.InputEncoding;
+#endif
+ }
+ }
+
+ public static Encoding OutputEncoding {
+ get {
+ if(!RunningOnWindows) {
+ return Encoding.Default;
+ }
+
+#if !NET_2_0
+ try {
+ return Encoding.GetEncoding (GetConsoleOutputCP ());
+ } catch {
+ return Encoding.GetEncoding (28591);
+ }
+#else
+ return Console.OutputEncoding;
+#endif
+ }
+ }
+ }
}
}