diff --git a/mods/irc/hooks.lua b/mods/irc/hooks.lua index 14e07f88..26432179 100644 --- a/mods/irc/hooks.lua +++ b/mods/irc/hooks.lua @@ -7,6 +7,20 @@ local b64e = require("mime").b64 irc.hooks = {} irc.registered_hooks = {} +local accent_chars = { {"À", "A"},{"Á", "A"},{"Â", "A"},{"Ã", "A"},{"Ä", "A"},{"Å", "A"},{"Ç", "C"},{"È", "E"},{"É", "E"},{"Ê", "E"}, + {"Ë", "E"},{"�", "I"},{"Í", "I"},{"�", "I"},{"Ï", "I"},{"Ñ", "N"},{"Ò", "O"},{"Ó", "O"},{"Ô", "O"},{"Õ", "O"}, + {"Ö", "O"},{"�", "O"},{"Ù", "U"},{"Ú", "U"},{"Û", "U"},{"Ü", "U"},{"�", "Y"},{"à", "a"},{"á", "a"},{"â", "a"}, + {"ã", "a"},{"ä", "a"},{"å", "a"},{"ç", "c"},{"è", "e"},{"é", "e"},{"ê", "e"},{"ë", "e"},{"ì", "i"},{"í", "i"}, + {"î", "i"},{"ï", "i"},{"ñ", "n"},{"ò", "o"},{"ó", "o"},{"ô", "o"},{"õ", "o"},{"ö", "o"},{"�", "o"},{"ù", "u"}, + {"ú", "u"},{"û", "u"},{"ü", "u"},{"�", "Y"} + } + +local function subaccent(text) + for _, c in pairs(accent_chars) do + text = text:gsub(c[1], c[2]) + end + return text:gsub(stripped_chars, "") +end -- TODO: Add proper conversion from CP1252 to UTF-8. local stripped_chars = {"\2", "\31"} @@ -18,7 +32,7 @@ stripped_chars = "["..table.concat(stripped_chars, "").."]" local function normalize(text) -- Strip colors text = text:gsub("\3[0-9][0-9,]*", "") - + text = subaccent(text) return text:gsub(stripped_chars, "") end diff --git a/other_things/irc-old-save/hooks.lua b/other_things/irc-old-save/hooks.lua index 6c8e2438..3d145056 100644 --- a/other_things/irc-old-save/hooks.lua +++ b/other_things/irc-old-save/hooks.lua @@ -7,6 +7,20 @@ local b64e = require("mime").b64 irc.hooks = {} irc.registered_hooks = {} +local accent_chars = { {"À", "A"},{"Á", "A"},{"Â", "A"},{"Ã", "A"},{"Ä", "A"},{"Å", "A"},{"Ç", "C"},{"È", "E"},{"É", "E"},{"Ê", "E"}, + {"Ë", "E"},{"�", "I"},{"Í", "I"},{"�", "I"},{"Ï", "I"},{"Ñ", "N"},{"Ò", "O"},{"Ó", "O"},{"Ô", "O"},{"Õ", "O"}, + {"Ö", "O"},{"�", "O"},{"Ù", "U"},{"Ú", "U"},{"Û", "U"},{"Ü", "U"},{"�", "Y"},{"à", "a"},{"á", "a"},{"â", "a"}, + {"ã", "a"},{"ä", "a"},{"å", "a"},{"ç", "c"},{"è", "e"},{"é", "e"},{"ê", "e"},{"ë", "e"},{"ì", "i"},{"í", "i"}, + {"î", "i"},{"ï", "i"},{"ñ", "n"},{"ò", "o"},{"ó", "o"},{"ô", "o"},{"õ", "o"},{"ö", "o"},{"�", "o"},{"ù", "u"}, + {"ú", "u"},{"û", "u"},{"ü", "u"},{"�", "Y"} + } + +local function subaccent(text) + for _, c in pairs(accent_chars) do + text = text:gsub(c[1], c[2]) + end + return text:gsub(stripped_chars, "") +end -- TODO: Add proper conversion from CP1252 to UTF-8. local stripped_chars = {"\2", "\31"} @@ -18,7 +32,7 @@ stripped_chars = "["..table.concat(stripped_chars, "").."]" local function normalize(text) -- Strip colors text = text:gsub("\3[0-9][0-9,]*", "") - + text = subaccent(text) return text:gsub(stripped_chars, "") end