Last active
July 8, 2023 13:54
-
-
Save imba-tjd/0a5a41df029babc6c814efe5d9296593 to your computer and use it in GitHub Desktop.
A program helps pwsh to read from utf8 output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This program helps pwsh to read from external program output from utf8 encoding. | |
// Compile: bflat build xargsu2a.cs -Ot --no-debug-info --no-globalization --no-reflection --no-stacktrace-data | |
// License: MIT | |
using System; | |
using System.Diagnostics; | |
using System.Text; | |
if (args.Length == 0) | |
{ | |
Console.Error.WriteLine("xargs utf8 to ansi:\nExample usage: xargsu2a git log > log.txt"); | |
return; | |
} | |
var spi = new ProcessStartInfo(args[0]) | |
{ | |
RedirectStandardOutput = true, | |
StandardOutputEncoding = Encoding.UTF8, | |
UseShellExecute = false, | |
}; | |
for (int i = 1; i < args.Length; i++) | |
spi.ArgumentList.Add(args[i]); | |
var p = Process.Start(spi); | |
string s = p.StandardOutput.ReadToEnd(); | |
Console.Write(s); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment