kalekje / LNCHR-pub

MIT License
25 stars 4 forks source link

Spreadsheet commands with special characters result in errors #6

Closed Avastgard closed 1 year ago

Avastgard commented 1 year ago

If I have a command with a special character in the spreadsheet, pressing Ctrl + L will generate a script with incorrect character.

For example, the command revisão will produce this line of code:

if ((input == "revis㯢) and (UsingAnyWorkcomputer)) ;  
{
close_lngui()

return
}

2023_11_16 @ 14_44_55 (523x166)

kalekje commented 1 year ago

Does the code work or no? I think this depends on the type of encoding you view your code in.

I tried: image Which generates the following when viewed on notepad++ with ANSI encoding: image But switching to UTF-8: image

kalekje commented 1 year ago

Maybe something like this will help: https://www.mrexcel.com/board/threads/vba-create-text-file-in-utf-8-rather-then-ansi.1204545/

Avastgard commented 1 year ago

Does the code work or no?

It doesn't. Sometimes it throws me an error message and prevents me from reloading the script. Other times, the script reloads, but the command fails every time. These behavior seem to be related to the kind of special character I use.

I think this depends on the type of encoding you view your code in.

I tried: image Which generates the following when viewed on notepad++ with ANSI encoding: image But switching to UTF-8: image

Yes, opening the code with notepad shows me the correct characters, but on Scite4AutoHotkey, it shows the weird character I posted in the OP.

How should I approach this? I'm thinking that since the macro recreates the script everytime it runs, then the issue should be in the way the macro always creates the file with ANSI encoding, no? I tried changing the encoding of LNCHR-Main.ahk to UTF-8 and UTF-8 without BOM, but everytime I ran the macro, the encoding defaulted back to ANSI.

Your suggestion from your second post might help, but it's a little too advanced for me. Might give it a shot some time in the future, though.

kalekje commented 1 year ago

Try changing the Flase to True in the VBA file as shown below, it seems to work for me:

image

From here: https://stackoverflow.com/a/10101320/11551386

Avastgard commented 1 year ago

Sweet, it worked and was far easier than I thought!

Sorry for opening so many issues, but I'm in the process of adopting your code as my daily driver and so many questions have been appearing so far. Thanks for your support!