Jump to content
  • Advertisement
Sign in to follow this  

System.Diagnostics.Process - Encoding output/Code page

This topic is 4132 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!