Hacker News new | ask | show | jobs
by elchief 3666 days 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

4 comments

This 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...)

I 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.

No 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.

That's a real bug, but I'm not sure that it means powershell is garbage.
I guess if problems with unicode are the bar for "garbage" then Ruby must be a garbage language?