4 ms·
Powershell is garbage. .Net does utf8 by default but powershell, built on .Net, manages not to. Try type utf8Encoded.txt > out.txt in cmd.exe and posh. Cmd wo
by elchief 10y ago
Powershell is garbage. .Net does utf8 by default but powershell, built on .Net, manages not to.
Try type utf8Encoded.txt > out.txt in cmd.exe and posh. Cmd works and posh fs it up.
And after you do figure out utf8 encoding in posh, it'll always add a BOM just to screw you
- stephengillie 10y agoThis has frustrated me to no end. I've given into using WriteAllLines as a work-around. [IO.File]::WriteAllLines($filename, $content) (from https://stackoverflow.com/questions/5596982/using-powershell-to-write-a-file-in-utf-8-without-the-bom https://stackoverflow.com/questions/5596982/using-powershell...)
- lqdc13 10y agoI get OOM with larger files even when they should fit in memory. Powershell is like a poor Java/C# interpreter instead of a quick and dirty shell.
- nailer 10y agoThat's a real bug, but I'm not sure that it means powershell is garbage.
- InclinedPlane 10y agoI guess if problems with unicode are the bar for "garbage" then Ruby must be a garbage language?
- userbinator 10y agoNo doubt the result of adding another layer of complexity: "type" in cmd is basically Unix cat, it just reads the file and writes it to standard output byte-for-byte. PS probably does some hidden encoding-autodetection and attempts to perform translation, but doesn't always get it right. You can see the difference in philosophy here, cmd (and bash, to a certain extent) are simple and don't try to do sneaky things silently, even if it means you might have to do a little more yourself e.g. performing character set translations explicitly. The behaviour is straightforward and predictable. PS attempts to be more "user-friendly" by doing some hidden conversions presumably so the user doesn't have to explicitly do character set translations, and when it works it works well; but when it fails, it fails spectacularly.