From 11e6bccb32d26ea4f1974186103a01e4b358c318 Mon Sep 17 00:00:00 2001 From: crabman77 Date: Sat, 18 Apr 2015 17:59:40 +0200 Subject: [PATCH] =?UTF-8?q?add=20substitute=20chars=20"=C3=A9=C3=A8=C3=A0"?= =?UTF-8?q?(no=20displayed)=20to=20"eea"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mods/irc/hooks.lua | 16 +++++++++++++++- other_things/irc-old-save/hooks.lua | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) 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