Except on Windows where everything is UTF16LE. Except when it isn't....
Trying to call a PowerShell script with an encoded argument was ... different. You have to encode your script as UTF16LE with no BOM then base64 encode that. Gruesome.
The PowerShell encoded argument back is only necessary because the quoting rules for windows are so utterly putrid - mainly due to its lack of argument vector support. Each executable has to parse its own arguments from single a char* string... and not all of them use the MSVCRT routines to do so. cmd.exe in particular is a crime against command lines. Then you have the spectacularly weird rules the "standard" argument parsing in MSVCRT has around quotes and backslashes... and the total lack of any WIN32 api to help you encode an argument vector as a command line to round trip it through CreateProcess intact even if the recipient does use the MSVCRT art handling. Oh, and did I mention that many interfaces like spawnv() or PowerShell's start-process -ArgumentListappear to take a structured argument array of vector.... then just join it all into one string with space separators and no quoting? None of which is documented? Frothing insanity.
View all comments
Show parent comment
2
u/nsl42 Jul 06 '21
The good ol' days pre-UTF-8 are starting to feel like a distant past. Even if I remember by heart my using of ISO-8859-1 ;)