Open dlutz52 opened 8 months ago
Just after I submitted this issue, I came across something on the Internet that made me try again. I ran the same command above in a Command Prompt and found I could not reproduce the issue. How weird! I gave it some thought and wondered whether I had used Command Prompt or Powershell originally. When I ran the same command in a Powershell window, I got a BIN file with spaces between characters. So it must be something with Powershell. I do not normally use Powershell since it is so loaded with features that it is difficult to use - current case is an example. I guess the solution to this problem is to use Command Prompt and not Powershell.
Powershell is available on linux too, have you tried that combination?
Maybe it's not safe to rely on stdout being binary clean. An easy workaround is to have a parameter for the file name to create instead of dumping binary data to stdout.
I installed Powershell on my Ubuntu machine and run the same command line in a PowerShell terminal. I ended up with a BIN file that did NOT have spaces between characters. This is the closest thing I could find on the Internet regarding this problem: https://stackoverflow.com/questions/75951299/wrong-encoding-when-redirecting-printed-unicode-characters-on-windows-powershell. The solution you mention sounds reasonable -- skip stdout altogether; but it could open up a whole new can of worms. Is it worth it? Just do not use PowerShell on Windows.
BTW, I found your email to me in an unexpected mail box. I have had no luck changing email address for my GitHub account to dlutz52@gmail.com as it would always tell me that email address was in use. It finally dawned on me that I had created a GitHub repo while in an old job where I used that email address for it. I have now rectified the situation. TL;DR: dlutz52@gmail.com is now associated with the GitHub account I use most. So be aware of that.
Running 'python3 say_hello.py > hello.bin' generates hello_win.bin in attached ZIP file on Windows (Windows 11 Pro for Workstations 22H2, OS Build: 22621.2428 with Windows Feature Experience Pack 1000.22674.1000.0). Running 'python3 say_hello.py > hello.bin' generates hello_lnx.bin in attached ZIP file on Linux (Ubuntu 22.04.3 LTS).
When viewing as HEX files (UltraEdit on Windows and Bless on Linux), note how spaces are inserted between characters on Windows but not on Linux.
hello.zip