39aldo39 / klfc

Keyboard Layout Files Creator
GNU General Public License v3.0
222 stars 12 forks source link

MS KLC 1.4 support? #29

Open mark-mcg opened 4 years ago

mark-mcg commented 4 years ago

Apologies if I've missed a setup option here, but I was looking to go from KLC -> JSON, and if i load any existing keyboard layout in KLC 1.4, save it, then attempt to parse it with klfc i get an error:

Active code page: 65001 klfc.exe: .\uk.klc: hGetContents: invalid argument (invalid byte sequence)

Having a quick look at the exported KLC examples, there appears to be a few more columns in the KLC file I created versus the example (see attached, generated by loading the existing UK keyboard layout).

uk.klc.txt

39aldo39 commented 4 years ago

I think the problem is the encoding. KLFC tries to use UTF-8 for everything, but on Windows it is complicated, and I am not sure what the right thing to do is. Could you try explicitly saving the file as UTF-8? I think Notepad++ for example can do that.

BTW, if the problem is in the file itself, you would get a more explicit error message.

mark-mcg commented 4 years ago

Spot on, converting to UTF8 in notepad++ resolved it, file parsed fine at that point. Thanks!

jpc-ae commented 2 years ago

VS Code opens 1.4 klc files as UTF-16 LE, I like this project so may try to add some improvements once I've looked over the code, but any way to add an error catch for this where it retries using UTF-16 large endian?

jarnowic commented 5 months ago

a pipe running iconv -f utf16 -t utf8 <filename>.klc | klfc --from-klc - <etc> did the trick for me...

DreymaR commented 5 months ago

Yes, MSKLC uses UTF-16 (LE) encoding natively. I don't think it'll work with other encodings? Therefore, KLFC should use this encoding too.

As pointed out in another recent issue, KLFC also needs to use CRLF line endings for KLC files. It should do so regardless of the OS it is run under.

See the EPKL MSKLC folder: https://github.com/DreymaR/BigBagKbdTrixPKL/tree/master/Other/MSKLC#technicalities