mv1f / pras3

Tools for controlling Sega P-ras 3 LED/NFC/VFD peripheral boards.
The Unlicense
2 stars 1 forks source link

Could not encode txt string with non UTF-8 characters #2

Open FutabaTori opened 5 months ago

FutabaTori commented 5 months ago

I was trying to run the script, my text has both American and Japanese text, if there is Japanese text is in the --text string it will cause an encode error. I think its a UTF error but I am not the most knowledgeable on this so good luck fixing it!

image

mv1f commented 5 months ago

Can you capture the text into a text file and attach it to this issue? Just change the last line to something like:

echo "C: \Program Files\Hi\pras3.exe" vfd --text " Aime cards are currently offline
Aimeカードは現在オフラインです"--brightness4 > output.txt

And then attach output.txt.

flottenheimer commented 5 months ago

Hi mv1f

For whatever it is worth):

When the exe is run directly from the command prompt, japanese characters work fine. When the exe is run from a bat (batch-file) — say, from within the startup-folder — japanese characters will not work.

I tried to read up on it weeks ago — and as far as I understand there are some special requirements for the encoding or decoding of the batch file. Some suggested saving it as ANSI, some that the codepage could be defined inside the bat using the chcp command, such as 'chcp 65001' and saving as UTF-8 without BOM and a lot of other suggestions.

All in all it seems to be some kind of hurdle within Windows 10 and the way it decodes bat/batch files (or perhaps how Notepad encodes them?). Not a problem with pras3.exe itself. ... or maybe it is something else entirely?

After an evening of struggle and trying different stuff out I gave up.

If someone was able to figure out a work-around or how-to it would be super nice. Or perhaps a feature could be added to the VFD 'command' supporting loading text from an external file?

Endless appreciation for the work you've done mv1f — and the exe has made everything so much easier to deal with.

Here is a link (perhaps) discussing this challenge: https://stackoverflow.com/questions/1485595/ja-chars-in-windows-batch-file

FutabaTori commented 5 months ago

Can you capture the text into a text file and attach it to this issue? Just change the last line to something like:

echo "C: \Program Files\Hi\pras3.exe" vfd --text " Aime cards are currently offline
Aimeカードは現在オフラインです"--brightness4 > output.txt

And then attach output.txt.

Sorry for late post, the output had nothing of note, only listing the command without listing the echo function. I also decided to attach the batch file (as a txt) I used in case that is helpful at all, but there isn't much to note in it. output.txt New Text Document.txt

mv1f commented 5 months ago

Don't worry about it. The file has exactly what I was looking for. I just wanted to try and see the text as it was written in the command.

Also thanks for the followup about the batch file text encoding issue. I never even considered that might be an issue but it makes sense (not in a good way, but you know...). On a cursory look everything does appear to be UTF-8. Text encoding really is a pain.

Loading the text from an external file isn't a bad idea but it's also got encoding issues to deal with and it's 'a bit annoying to have to keep the text in a separate file. I've taken a stab at what I think would be a simple solution and attached a test build. Can you give it a try and tell me how it goes? Take your script and add --utf8 to the options. Assuming your file is UTF-8 encoded (what you attached appears to be) it should force the tool to interpret the string as UTF-8.

pras3_windows.zip