This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/miku/encoding.lua

355 lines
21 KiB
Lua
Raw Normal View History

-- See http://www.ascii.cl/htmlcodes.htm
-- str = string.gsub(str, '', '')
2016-08-16 13:05:26 +02:00
function unescape(str)
-- Symbols
str = string.gsub(str, ' ', ' ') -- space
str = string.gsub(str, '!', '!') -- exclamation point
str = string.gsub(str, '"', '"') -- double quotes
str = string.gsub(str, '"', '"') -- double quotes
str = string.gsub(str, '#', '#') -- number sign
str = string.gsub(str, '$', '$') -- dollar sign
str = string.gsub(str, '%', '%') -- percent sign
str = string.gsub(str, ''', '\'') -- single quote
str = string.gsub(str, '(', '(') -- opening parenthesis
str = string.gsub(str, ')', ')') -- closing parenthesis
str = string.gsub(str, '*', '*') -- asterisk
str = string.gsub(str, '+', '+') -- plus sign
str = string.gsub(str, ',', ',') -- comma
str = string.gsub(str, '-', '-') -- minus sign - hyphen
str = string.gsub(str, '.', '.') -- period
str = string.gsub(str, '/', '/') -- slash
str = string.gsub(str, ':', ':') -- colon
str = string.gsub(str, '&#59;', ';') -- semicolon
str = string.gsub(str, '&#60;', '<') -- less than sign
str = string.gsub(str, '&lt;', '<') -- less than sign
str = string.gsub(str, '&#61;', '=') -- equal sign
str = string.gsub(str, '&#62;', '>') -- greater than sign
str = string.gsub(str, '&gt;', '>') -- greater than sign
str = string.gsub(str, '&#63;', '?') -- question mark
str = string.gsub(str, '&#64;', '@') -- at symbol
str = string.gsub(str, '&#91;', '[') -- opening bracket
str = string.gsub(str, '&#92;', '\\') -- backslash
str = string.gsub(str, '&#93;', ']') -- closing bracket
str = string.gsub(str, '&#94;', '^') -- caret - circumflex
str = string.gsub(str, '&#95;', '_') -- underscore
str = string.gsub(str, '&#96;', '`') -- grave accent
str = string.gsub(str, '&#123;', '{') -- opening brace
str = string.gsub(str, '&#124;', '|') -- vertical bar
str = string.gsub(str, '&#125;', '}') -- closing brace
str = string.gsub(str, '&#126;', '~') -- equivalency sign - tilde
str = string.gsub(str, '&#160;', ' ') -- non-breaking space
str = string.gsub(str, '&nbsp;', ' ') -- non-breaking space
str = string.gsub(str, '&#161;', '¡') -- inverted exclamation mark
str = string.gsub(str, '&iexcl;', '¡') -- inverted exclamation mark
str = string.gsub(str, '&#162;', '¢') -- cent sign
str = string.gsub(str, '&cent;', '¢') -- cent sign
str = string.gsub(str, '&#163;', '£') -- pound sign
str = string.gsub(str, '&pound;', '£') -- pound sign
str = string.gsub(str, '&#164;', '¤') -- currency sign
str = string.gsub(str, '&curren;', '¤') -- currency sign
str = string.gsub(str, '&#165;', '¥') -- yen sign
str = string.gsub(str, '&yen;', '¥') -- yen sign
str = string.gsub(str, '&#166;', '¦') -- broken vertical bar
str = string.gsub(str, '&brvbar;', '¦') -- broken vertical bar
str = string.gsub(str, '&#167;', '§') -- section sign
str = string.gsub(str, '&sect;', '§') -- section sign
str = string.gsub(str, '&#168;', '¨') -- spacing diaeresis - umlaut
str = string.gsub(str, '&uml;', '¨') -- spacing diaeresis - umlaut
str = string.gsub(str, '&#169;', '©') -- copyright sign
str = string.gsub(str, '&copy;', '©') -- copyright sign
str = string.gsub(str, '&#170;', 'ª') -- feminine ordinal indicator
str = string.gsub(str, '&ordf;', 'ª') -- feminine ordinal indicator
str = string.gsub(str, '&#171;', '«') -- left double angle quotes
str = string.gsub(str, '&laquo;', '«') -- left double angle quotes
str = string.gsub(str, '&#172;', '¬') -- not sign
str = string.gsub(str, '&not;', '¬') -- not sign
str = string.gsub(str, '&#173;', '') -- soft hyphen
str = string.gsub(str, '&shy;', '') -- soft hyphen
str = string.gsub(str, '&#174;', '®') -- registered trade mark sign
str = string.gsub(str, '&reg;', '®') -- registered trade mark sign
str = string.gsub(str, '&#175;', '¯') -- spacing macron - overline
str = string.gsub(str, '&macr;', '¯') -- spacing macron - overline
str = string.gsub(str, '&#176;', '°') -- degree sign
str = string.gsub(str, '&deg;', '°') -- degree sign
str = string.gsub(str, '&#177;', '±') -- plus-or-minus sign
str = string.gsub(str, '&plusmn;', '±') -- plus-or-minus sign
str = string.gsub(str, '&#178;', '²') -- superscript two - squared
str = string.gsub(str, '&sup2;', '²') -- superscript two - squared
str = string.gsub(str, '&#179;', '³') -- superscript three - cubed
str = string.gsub(str, '&sup3;', '³') -- superscript three - cubed
str = string.gsub(str, '&#180;', '´') -- acute accent - spacing acute
str = string.gsub(str, '&acute;', '´') -- acute accent - spacing acute
str = string.gsub(str, '&#181;', 'µ') -- micro sign
str = string.gsub(str, '&micro;', 'µ') -- micro sign
str = string.gsub(str, '&#182;', '') -- pilcrow sign - paragraph sign
str = string.gsub(str, '&para;', '') -- pilcrow sign - paragraph sign
str = string.gsub(str, '&#183;', '·') -- middle dot - Georgian comma
str = string.gsub(str, '&middot;', '·') -- middle dot - Georgian comma
str = string.gsub(str, '&#184;', '¸') -- spacing cedilla
str = string.gsub(str, '&cedil;', '¸') -- spacing cedilla
str = string.gsub(str, '&#185;', '¹') -- superscript one
str = string.gsub(str, '&sup1;', '¹') -- superscript one
str = string.gsub(str, '&#186;', 'º') -- masculine ordinal indicator
str = string.gsub(str, '&ordm;', 'º') -- masculine ordinal indicator
str = string.gsub(str, '&#187;', '»') -- right double angle quotes
str = string.gsub(str, '&raquo;', '»') -- right double angle quotes
str = string.gsub(str, '&#188;', '¼') -- fraction one quarter
str = string.gsub(str, '&frac14;', '¼') -- fraction one quarter
str = string.gsub(str, '&#189;', '½') -- fraction one half
str = string.gsub(str, '&frac12;', '½') -- fraction one half
str = string.gsub(str, '&#190;', '¾') -- fraction three quarters
str = string.gsub(str, '&frac34;', '¾') -- fraction three quarters
str = string.gsub(str, '&#191;', '¿') -- inverted question mark
str = string.gsub(str, '&iquest;', '¿') -- inverted question mark
str = string.gsub(str, '&#215;', '×') -- multiplication sign
str = string.gsub(str, '&times;', '×') -- multiplication sign
str = string.gsub(str, '&#247;', '÷') -- division sign
str = string.gsub(str, '&divide;', '÷') -- division sign
str = string.gsub(str, '&#8211;', '') -- en dash
str = string.gsub(str, '&ndash;', '') -- en dash
str = string.gsub(str, '&#8212;', '') -- em dash
str = string.gsub(str, '&mdash;', '') -- em dash
str = string.gsub(str, '&#8216;', '') -- left single quotation mark
str = string.gsub(str, '&lsquo;', '') -- left single quotation mark
str = string.gsub(str, '&#8217;', '') -- right single quotation mark
str = string.gsub(str, '&rsquo;', '') -- right single quotation mark
str = string.gsub(str, '&#8218;', '') -- single low-9 quotation mark
str = string.gsub(str, '&sbquo;', '') -- single low-9 quotation mark
str = string.gsub(str, '&#8220;', '') -- left double quotation mark
str = string.gsub(str, '&ldquo;', '') -- left double quotation mark
str = string.gsub(str, '&#8221;', '') -- right double quotation mark
2016-08-05 13:19:05 +02:00
str = string.gsub(str, '&rdquo;', '') -- right double quotation mark
str = string.gsub(str, '&#8222;', '') -- double low-9 quotation mark
str = string.gsub(str, '&bdquo;', '') -- double low-9 quotation mark
str = string.gsub(str, '&#8224;', '') -- dagger
2016-08-05 13:19:05 +02:00
str = string.gsub(str, '&dagger;', '') -- dagger
str = string.gsub(str, '&#8225;', '') -- double dagger
2016-08-05 13:19:05 +02:00
str = string.gsub(str, '&Dagger;', '') -- double dagger
str = string.gsub(str, '&#8226;', '') -- bullet
2016-08-05 13:19:05 +02:00
str = string.gsub(str, '&bull;', '') -- bullet
str = string.gsub(str, '&#8230;', '') -- horizontal ellipsis
2016-08-05 13:19:05 +02:00
str = string.gsub(str, '&hellip;', '') -- horizontal ellipsis
str = string.gsub(str, '&#8240;', '') -- per thousand sign
2016-08-05 13:19:05 +02:00
str = string.gsub(str, '&permil;', '') -- per thousand sign
str = string.gsub(str, '&#8264;', '') -- euro sign
str = string.gsub(str, '&euro;', '') -- euro sign
2016-08-05 13:19:05 +02:00
str = string.gsub(str, '&#8482;', '') -- trade mark sign
str = string.gsub(str, '&trade;', '') -- trade mark sign
-- Numbers
str = string.gsub(str, '&#48;', '0') -- zero
str = string.gsub(str, '&#49;', '1') -- one
str = string.gsub(str, '&#50;', '2') -- two
str = string.gsub(str, '&#51;', '3') -- three
str = string.gsub(str, '&#52;', '4') -- four
str = string.gsub(str, '&#53;', '5') -- five
str = string.gsub(str, '&#54;', '6') -- six
str = string.gsub(str, '&#55;', '7') -- seven
str = string.gsub(str, '&#56;', '8') -- eight
str = string.gsub(str, '&#57;', '9') -- nine
-- Big letters
str = string.gsub(str, '&#65;', 'A')
str = string.gsub(str, '&#66;', 'B')
str = string.gsub(str, '&#67;', 'C')
str = string.gsub(str, '&#68;', 'D')
str = string.gsub(str, '&#69;', 'E')
str = string.gsub(str, '&#70;', 'F')
str = string.gsub(str, '&#71;', 'G')
str = string.gsub(str, '&#72;', 'H')
str = string.gsub(str, '&#73;', 'I')
str = string.gsub(str, '&#74;', 'J')
str = string.gsub(str, '&#75;', 'K')
str = string.gsub(str, '&#76;', 'L')
str = string.gsub(str, '&#77;', 'M')
str = string.gsub(str, '&#78;', 'N')
str = string.gsub(str, '&#79;', 'O')
str = string.gsub(str, '&#80;', 'P')
str = string.gsub(str, '&#81;', 'Q')
str = string.gsub(str, '&#82;', 'R')
str = string.gsub(str, '&#83;', 'S')
str = string.gsub(str, '&#84;', 'T')
str = string.gsub(str, '&#85;', 'U')
str = string.gsub(str, '&#86;', 'V')
str = string.gsub(str, '&#87;', 'W')
str = string.gsub(str, '&#88;', 'X')
str = string.gsub(str, '&#89;', 'Y')
str = string.gsub(str, '&#90;', 'Z')
-- Small letters
str = string.gsub(str, '&#97;', 'a')
str = string.gsub(str, '&#98;', 'b')
str = string.gsub(str, '&#99;', 'c')
str = string.gsub(str, '&#100;', 'd')
str = string.gsub(str, '&#101;', 'e')
str = string.gsub(str, '&#102;', 'f')
str = string.gsub(str, '&#103;', 'g')
str = string.gsub(str, '&#104;', 'h')
str = string.gsub(str, '&#105;', 'i')
str = string.gsub(str, '&#106;', 'j')
str = string.gsub(str, '&#107;', 'k')
str = string.gsub(str, '&#108;', 'l')
str = string.gsub(str, '&#109;', 'm')
str = string.gsub(str, '&#110;', 'n')
str = string.gsub(str, '&#111;', 'o')
str = string.gsub(str, '&#112;', 'p')
str = string.gsub(str, '&#113;', 'q')
str = string.gsub(str, '&#114;', 'r')
str = string.gsub(str, '&#115;', 's')
str = string.gsub(str, '&#116;', 't')
str = string.gsub(str, '&#117;', 'u')
str = string.gsub(str, '&#118;', 'v')
str = string.gsub(str, '&#119;', 'w')
str = string.gsub(str, '&#120;', 'x')
str = string.gsub(str, '&#121;', 'y')
str = string.gsub(str, '&#122;', 'z')
-- Latin capital letters
str = string.gsub(str, '&#192;', 'À') -- latin capital letter A with grave
str = string.gsub(str, '&Agrave;', 'À') -- latin capital letter A with grave
str = string.gsub(str, '&#193;', 'Á') -- latin capital letter A with acute
str = string.gsub(str, '&Aacute;', 'Á') -- latin capital letter A with acute
str = string.gsub(str, '&#194;', 'Â') -- latin capital letter A with circumflex
str = string.gsub(str, '&Acirc;', 'Â') -- latin capital letter A with circumflex
str = string.gsub(str, '&#195;', 'Ã') -- latin capital letter A with tilde
str = string.gsub(str, '&Atilde;', 'Ã') -- latin capital letter A with tilde
str = string.gsub(str, '&#196;', 'Ä') -- latin capital letter A with diaeresis
str = string.gsub(str, '&Auml;', 'Ä') -- latin capital letter A with diaeresis
str = string.gsub(str, '&#197;', 'Å') -- latin capital letter A with ring above
str = string.gsub(str, '&Aring;', 'Å') -- latin capital letter A with ring above
str = string.gsub(str, '&#198;', 'Æ') -- latin capital letter AE
str = string.gsub(str, '&AElig;', 'Æ') -- latin capital letter AE
str = string.gsub(str, '&#199;', 'Ç') -- latin capital letter C with cedilla
str = string.gsub(str, '&Ccedil;', 'Ç') -- latin capital letter C with cedilla
str = string.gsub(str, '&#200;', 'È') -- latin capital letter E with grave
str = string.gsub(str, '&Egrave;', 'È') -- latin capital letter E with grave
str = string.gsub(str, '&#201;', 'É') -- latin capital letter E with acute
str = string.gsub(str, '&Eacute;', 'É') -- latin capital letter E with acute
str = string.gsub(str, '&#202;', 'Ê') -- latin capital letter E with circumflex
str = string.gsub(str, '&Ecirc;', 'Ê') -- latin capital letter E with circumflex
str = string.gsub(str, '&#203;', 'Ë') -- latin capital letter E with diaeresis
str = string.gsub(str, '&Euml;', 'Ë') -- latin capital letter E with diaeresis
str = string.gsub(str, '&#204;', 'Ì') -- latin capital letter I with grave
str = string.gsub(str, '&Igrave;', 'Ì') -- latin capital letter I with grave
str = string.gsub(str, '&#205;', 'Í') -- latin capital letter I with acute
str = string.gsub(str, '&Iacute;', 'Í') -- latin capital letter I with acute
str = string.gsub(str, '&#206;', 'Î') -- latin capital letter I with circumflex
str = string.gsub(str, '&Icirc;', 'Î') -- latin capital letter I with circumflex
str = string.gsub(str, '&#207;', 'Ï') -- latin capital letter I with diaeresis
str = string.gsub(str, '&Iuml;', 'Ï') -- latin capital letter I with diaeresis
str = string.gsub(str, '&#208;', 'Ð') -- latin capital letter ETH
str = string.gsub(str, '&ETH;', 'Ð') -- latin capital letter ETH
str = string.gsub(str, '&#209;', 'Ñ') -- latin capital letter N with tilde
str = string.gsub(str, '&Ntilde;', 'Ñ') -- latin capital letter N with tilde
str = string.gsub(str, '&#210;', 'Ò') -- latin capital letter O with grave
str = string.gsub(str, '&Ograve;', 'Ò') -- latin capital letter O with grave
str = string.gsub(str, '&#211;', 'Ó') -- latin capital letter O with acute
str = string.gsub(str, '&Oacute;', 'Ó') -- latin capital letter O with acute
str = string.gsub(str, '&#212;', 'Ô') -- latin capital letter O with circumflex
str = string.gsub(str, '&Ocrc;', 'Ô') -- latin capital letter O with circumflex
str = string.gsub(str, '&#213;', 'Õ') -- latin capital letter O with tilde
str = string.gsub(str, '&Otilde;', 'Õ') -- latin capital letter O with tilde
str = string.gsub(str, '&#214;', 'Ö') -- latin capital letter O with diaeresis
str = string.gsub(str, '&Ouml;', 'Ö') -- latin capital letter O with diaeresis
str = string.gsub(str, '&#216;', 'Ø') -- latin capital letter O with slash
str = string.gsub(str, '&Oslash;', 'Ø') -- latin capital letter O with slash
str = string.gsub(str, '&#217;', 'Ù') -- latin capital letter U with grave
str = string.gsub(str, '&Ugrave;', 'Ù') -- latin capital letter U with grave
str = string.gsub(str, '&#218;', 'Ú') -- latin capital letter U with acute
str = string.gsub(str, '&Uacute;', 'Ú') -- latin capital letter U with acute
str = string.gsub(str, '&#219;', 'Û') -- latin capital letter U with circumflex
str = string.gsub(str, '&Ucirc;', 'Û') -- latin capital letter U with circumflex
str = string.gsub(str, '&#220;', 'Ü') -- latin capital letter U with diaeresis
str = string.gsub(str, '&Uuml;', 'Ü') -- latin capital letter U with diaeresis
str = string.gsub(str, '&#221;', 'Ý') -- latin capital letter Y with acute
str = string.gsub(str, '&Yacute;', 'Ý') -- latin capital letter Y with acute
str = string.gsub(str, '&#222;', 'Þ') -- latin capital letter THORN
str = string.gsub(str, '&THORN;', 'Þ') -- latin capital letter THORN
str = string.gsub(str, '&#338;', 'Œ') -- latin capital letter OE
str = string.gsub(str, '&#352;', 'Š') -- latin capital letter S with caron
str = string.gsub(str, '&#376;', 'Ÿ') -- latin capital letter Y with diaeresis
-- Latin small letters
str = string.gsub(str, '&#223;', 'ß') -- latin small letter sharp s - ess-zed
str = string.gsub(str, '&szlig;', 'ß') -- latin small letter sharp s - ess-zed
str = string.gsub(str, '&#224;', 'à') -- latin small letter a with grave
str = string.gsub(str, '&agrave;', 'à') -- latin small letter a with grave
str = string.gsub(str, '&#225;', 'á') -- latin small letter a with acute
str = string.gsub(str, '&aacute;', 'á') -- latin small letter a with acute
str = string.gsub(str, '&#226;', 'â') -- latin small letter a with circumflex
str = string.gsub(str, '&acirc;', 'â') -- latin small letter a with circumflex
str = string.gsub(str, '&#227;', 'ã') -- latin small letter a with tilde
str = string.gsub(str, '&atilde;', 'ã') -- latin small letter a with tilde
str = string.gsub(str, '&#228;', 'ä') -- latin small letter a with diaeresis
str = string.gsub(str, '&auml;', 'ä') -- latin small letter a with diaeresis
str = string.gsub(str, '&#229;', 'å') -- latin small letter a with ring above
str = string.gsub(str, '&aring;', 'å') -- latin small letter a with ring above
str = string.gsub(str, '&#230;', 'æ') -- latin small letter ae
str = string.gsub(str, '&aelig;', 'æ') -- latin small letter ae
str = string.gsub(str, '&#231;', 'ç') -- latin small letter c with cedilla
str = string.gsub(str, '&ccedil;', 'ç') -- latin small letter c with cedilla
str = string.gsub(str, '&#232;', 'è') -- latin small letter e with grave
str = string.gsub(str, '&egrave;', 'è') -- latin small letter e with grave
str = string.gsub(str, '&#233;', 'é') -- latin small letter e with acute
str = string.gsub(str, '&eacute;', 'é') -- latin small letter e with acute
str = string.gsub(str, '&#234;', 'ê') -- latin small letter e with circumflex
str = string.gsub(str, '&ecirc;', 'ê') -- latin small letter e with circumflex
str = string.gsub(str, '&#235;', 'ë') -- latin small letter e with diaeresis
str = string.gsub(str, '&euml;', 'ë') -- latin small letter e with diaeresis
str = string.gsub(str, '&#236;', 'ì') -- latin small letter i with grave
str = string.gsub(str, '&igrave;', 'ì') -- latin small letter i with grave
str = string.gsub(str, '&#237;', 'í') -- latin small letter i with acute
str = string.gsub(str, '&iacute;', 'í') -- latin small letter i with acute
str = string.gsub(str, '&#238;', 'î') -- latin small letter i with circumflex
str = string.gsub(str, '&icirc;', 'î') -- latin small letter i with circumflex
str = string.gsub(str, '&#239;', 'ï') -- latin small letter i with diaeresis
str = string.gsub(str, '&iuml;', 'ï') -- latin small letter i with diaeresis
str = string.gsub(str, '&#240;', 'ð') -- latin small letter eth
str = string.gsub(str, '&eth;', 'ð') -- latin small letter eth
str = string.gsub(str, '&#241;', 'ñ') -- latin small letter n with tilde
str = string.gsub(str, '&ntilde;', 'ñ') -- latin small letter n with tilde
str = string.gsub(str, '&#242;', 'ò') -- latin small letter o with grave
str = string.gsub(str, '&ograve;', 'ò') -- latin small letter o with grave
str = string.gsub(str, '&#243;', 'ó') -- latin small letter o with acute
str = string.gsub(str, '&oacute;', 'ó') -- latin small letter o with acute
str = string.gsub(str, '&#244;', 'ô') -- latin small letter o with circumflex
str = string.gsub(str, '&ocirc;', 'ô') -- latin small letter o with circumflex
str = string.gsub(str, '&#245;', 'õ') -- latin small letter o with tilde
str = string.gsub(str, '&otilde;', 'õ') -- latin small letter o with tilde
str = string.gsub(str, '&#246;', 'ö') -- latin small letter o with diaeresis
str = string.gsub(str, '&ouml;', 'ö') -- latin small letter o with diaeresis
str = string.gsub(str, '&#248;', 'ø') -- latin small letter o with slash
str = string.gsub(str, '&oslash;', 'ø') -- latin small letter o with slash
str = string.gsub(str, '&#249;', 'ù') -- latin small letter u with grave
str = string.gsub(str, '&ugrave;', 'ù') -- latin small letter u with grave
str = string.gsub(str, '&#250;', 'ú') -- latin small letter u with acute
str = string.gsub(str, '&uacute;', 'ú') -- latin small letter u with acute
str = string.gsub(str, '&#251;', 'û') -- latin small letter u with circumflex
str = string.gsub(str, '&ucirc;', 'û') -- latin small letter u with circumflex
str = string.gsub(str, '&#252;', 'ü') -- latin small letter u with diaeresis
str = string.gsub(str, '&uuml;', 'ü') -- latin small letter u with diaeresis
str = string.gsub(str, '&#253;', 'ý') -- latin small letter y with acute
str = string.gsub(str, '&yacute;', 'ý') -- latin small letter y with acute
str = string.gsub(str, '&#254;', 'þ') -- latin small letter thorn
str = string.gsub(str, '&thorn;', 'þ') -- latin small letter thorn
str = string.gsub(str, '&#255;', 'ÿ') -- latin small letter y with diaeresis
str = string.gsub(str, '&yuml;', 'ÿ') -- latin small letter y with diaeresis
str = string.gsub(str, '&#339;', 'œ') -- latin small letter oe
str = string.gsub(str, '&#353;', 'š') -- latin small letter s with caron
str = string.gsub(str, '&#402;', 'ƒ') -- latin small f with hook - function
2016-08-05 13:19:05 +02:00
-- Special
-- Emoticons (more soon)
str = string.gsub(str, '&#11088;&#65039;', '⭐️')
2016-08-05 13:19:05 +02:00
-- Japanese Katakana/Kanji (See http://symbolcodes.tlt.psu.edu/bylanguage/japanesechartkatakana.html)
-- Japanese Hiragana (Need a table...)
-- Be sure to do this after all others
str = string.gsub(str, '&#38;', '&') -- amper sand
str = string.gsub(str, '&amp;', '&') -- amper sand
return str
end