System.Diagnostics.Process - Encoding output/Code page

Started by
0 comments, last by Wildfire 17 years, 2 months ago
Does anyone know how to get localized/properly encoded output from a System.Diagnostics.Process? See example below. I tried toying around with the StartInfo.Encoding-Property to no avail. Google isn't really helpful either.

C:\...\>ping something

Output is:
Ping-Anforderung konnte Host "something" nicht finden. šberprfen Sie den Namen, und versuchen Sie es erneut.

Output should be:
Ping-Anforderung konnte Host "something" nicht finden. überprüfen Sie den Namen, und versuchen Sie es erneut.
This works correctly from the command line.
How do I set my laser printer on stun?
Advertisement
I think I have found a (partial) solution:

ProcessStartInfo psi = new ProcessStartInfo();psi.StandardOutputEncoding = Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentUICulture.TextInfo.OEMCodePage);


This will change the encoding to the codepage used by the specific language version of windows.

Does anyone know if this will work in all cases? The command line seems to "speak" the language of the operating system not paying attention to the users language and regional settings. So I should get away with using the OEMCodePage?

I tried using the ".ANSICodePage", the description suggests that this will return the code page used by the current culture. However, even though the culture is set to "de-DE" it gives me CP 1252 (US) instead of CP 850 (German) as I would expect.
How do I set my laser printer on stun?

This topic is closed to new replies.

Advertisement