From bb955ab8b9a866600d53a5ee52c7e965011137b5 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sat, 17 Jun 2023 12:19:49 -0700 Subject: [PATCH] Add new `generate-case-insensitive-mapping.js` to make generating mappings easier. --- script/generate-case-insensitive-mapping.js | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 script/generate-case-insensitive-mapping.js diff --git a/script/generate-case-insensitive-mapping.js b/script/generate-case-insensitive-mapping.js new file mode 100644 index 000000000..7256863b8 --- /dev/null +++ b/script/generate-case-insensitive-mapping.js @@ -0,0 +1,50 @@ +const mappings = [ + /* basic Russian: https://github.com/clangen/musikcube/issues/613 */ + 'а:А', + 'б:Б', + 'в:В', + 'г:Г', + 'д:Д', + 'е:Е', + 'ё:Ё', + 'ж:Ж', + 'з:З', + 'и:И', + 'й:Й', + 'к:К', + 'л:Л', + 'м:М', + 'н:Н', + 'о:О', + 'п:П', + 'р:Р', + 'с:С', + 'т:Т', + 'у:У', + 'ф:Ф', + 'х:Х', + 'ц:Ц', + 'ч:Ч', + 'ш:Ш', + 'щ:Щ', + 'ъ:Ъ', + 'ы:Ы', + 'ь:Ь', + 'э:Э', + 'ю:Ю', + 'я:Я', +]; + +String.prototype.toHex = function () { + var result = ''; + for (var i = 0; i < this.length; i++) { + result += this.charCodeAt(i).toString(16); + } + return '0x' + result; +}; + +for (let i = 0; i < mappings.length; i++) { + const parts = mappings[i].split(':'); + parts[1] = [parts[1], parts[0]]; + console.log(`{ (u32)${parts[0].toHex()} /* ${parts[0]} */, u8"${parts[1].join('')}" },`); +}