MS KLC 1.4 support?
mark-mcg opened this issue · 5 comments
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).
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.
Spot on, converting to UTF8 in notepad++ resolved it, file parsed fine at that point. Thanks!
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?
a pipe running iconv -f utf16 -t utf8 <filename>.klc | klfc --from-klc - <etc>
did the trick for me...
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