Encoding UTF8-C# - Prozess

Ich habe eine Anwendung, die Prozess des vbscript und erzeugt die Ausgabe.

private static string processVB(string command, string arguments)
{
    Process Proc = new Process();
    Proc.StartInfo.UseShellExecute = false;
    Proc.StartInfo.RedirectStandardOutput = true;
    Proc.StartInfo.RedirectStandardError = true;
    Proc.StartInfo.RedirectStandardInput = true;
    Proc.StartInfo.StandardOutputEncoding = Encoding.UTF8;
    Proc.StartInfo.StandardErrorEncoding = Encoding.UTF8;
    Proc.StartInfo.FileName = command;
    Proc.StartInfo.Arguments = arguments;
    Proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //prevent console      window from popping up
    Proc.Start();
    string output = Proc.StandardOutput.ReadToEnd();
    string error = Proc.StandardError.ReadToEnd();

    if (String.IsNullOrEmpty(output) && !String.IsNullOrEmpty(error))
    {
        output = error;
    }
    //Console.Write(ping_output);

    Proc.WaitForExit();
    Proc.Close();

    return output;
}

Ich denke, ich habe alles, was mit Encoding-Eigenschaft korrekt ist. processVB Methode get-Befehl als VBscript-Datei und deren Argumenten.

Die C# - Methode processVB ist die Verarbeitung, die VBScript-Datei produzieren nun die Ausgabe wie folgt.

"����?"

Aber ich sollte original text

"äåéö€"

Habe ich die Codierung korrekt. Aber ich bin nicht in der Lage, es richtig zu machen.

Was mache ich falsch?

  • Haben Sie dies erlebt? stackoverflow.com/questions/7520706/... - ich glaube, das ist genau Ihr problem.
  • Ja, ich habe es gesehen. Vielen Dank für die Referenz. Nein, Es hat nicht lösen, mein Problem.
  • Der link erklärt die Wurzel des Problems.
  • Was bedeutet CurrentEncoding-Eigenschaft hat für die StandardOutput-direkt nach dem Start des Prozesses?
  • System.Text.Bei UTF8Encoding
InformationsquelleAutor BinaryMee | 2014-03-13
Schreibe einen Kommentar