From c00f10ee1b547042c430352a30c0e1ff18eff949 Mon Sep 17 00:00:00 2001 From: Manassarn Manoonchai Date: Wed, 7 Jul 2021 22:09:34 +0700 Subject: [PATCH] fix: Correct Windows specific issues : utf16, BOM --- input/Manoonchai.json | 1 + main.ts | 17 +++++++++-------- output/test.klc | Bin 1690 -> 1686 bytes test/main.test.ts | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/input/Manoonchai.json b/input/Manoonchai.json index 02a6f64..4c17625 100644 --- a/input/Manoonchai.json +++ b/input/Manoonchai.json @@ -6,6 +6,7 @@ "license": "MIT", "os": { "windows": { + "installerName": "ThaiMnc", "company": "Manoonchai", "localeId": "0000041e" } diff --git a/main.ts b/main.ts index 8dd1df5..1fb78b3 100644 --- a/main.ts +++ b/main.ts @@ -105,7 +105,7 @@ export async function generateKlc( } const lines = [ - `KBD\t${layout.name}\t"${layout.language} ${layout.name} v${layout.version}"`, + `KBD\t${layout.os.windows.installerName}\t"${layout.language} ${layout.name} v${layout.version}"`, `COPYRIGHT\t"MIT"`, `COMPANY\t"${layout.os.windows.company}"`, `LOCALENAME\t"${klcLocales[layout.language]}"`, @@ -132,12 +132,13 @@ export async function generateKlc( fs.writeFileSync( "./output/test.klc", - [ - lines.join("\r\n\r\n"), - shiftStateLines.join("\r\n"), - layoutLines.join("\r\n"), - "ENDKBD", - ].join("\r\n\r\n"), + "\ufeff" + + [ + lines.join("\r\n\r\n"), + shiftStateLines.join("\r\n"), + layoutLines.join("\r\n"), + "ENDKBD", + ].join("\r\n\r\n"), { encoding: "utf16le", } @@ -434,5 +435,5 @@ export class Layout { } interface OSAttributes { - windows: { company: string; localeId: string } + windows: { company: string; localeId: string; installerName: string } } diff --git a/output/test.klc b/output/test.klc index 3810314e823106d9dc6ba4aa57e45795f3860803..7a0a642f8d5cde1eb5a354730d0035df3726fc71 100644 GIT binary patch delta 32 ncmbQmJB?TT|37aACk7V=PKFSM42DF8Oa@ { .filter(Boolean) // Assert file headers - expect(lines[0]).toEqual(`KBD\tManoonchai\t"Thai Manoonchai v1.0"`) + expect(lines[0]).toEqual(`\ufeffKBD\tThaiMnc\t"Thai Manoonchai v1.0"`) expect(lines[1]).toEqual(`COPYRIGHT\t"MIT"`) expect(lines[2]).toEqual(`COMPANY\t"Manoonchai"`) expect(lines[3]).toEqual(`LOCALENAME\t"th-TH"`)