Does Process.StartInfo.Arguments support a UTF-8 string?

Posted by Patrick Klug on Stack Overflow See other posts from Stack Overflow or by Patrick Klug
Published on 2010-04-13T08:03:08Z Indexed on 2010/04/13 8:13 UTC
Read the original article Hit count: 377

Filed under:
|

Can you use a UTF-8 string as the Arguments for a StartInfo?

I am trying to pass a UTF-8 (in this case a Japanese string) to an application as a console argument.

Something like this (this is just an example! (cmd.exe would be a custom app))

var process = new System.Diagnostics.Process();
process.StartInfo.Arguments = "/K \"echo ????????\"";
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = true;

process.Start();
process.WaitForExit();

Executing this seems to loose the UTF-8 string and all the target application sees is "echo ?????????"

When executing this command directly on the command line (by pasting the arguments) the target application receives the string correctly even though the command line itself doesn't seem to display it correctly.

Do I need to do anything special to enable UTF-8 support in the arguments or is this just not supported?

© Stack Overflow or respective owner

Related posts about c#

Related posts about utf-8