123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- htmlEscape = { "☺", "☻", "♥", "♦", "♣", "♠", "•", -- ASCII 1-7 (symbols for control characters, see code page 437)
- "◘", "○", "◙", "♂", "♀", "♪", "♫", "☼", -- ASCII 8-15
- "►", "◄", "↕", "‼", "¶", "§", "▬", "↨", -- ASCII 16-23
- "↑", "↓", "↨", "←", "∟", "→", "▲", "▼", -- ASCII 24-31
- " ", "!", """, "#", "$", "%", "&", "'", -- ASCII 32-39
- "(", ")", "*", "+", ",", "-", ".", "/", -- ASCII 40-47
- "0", "1", "2", "3", "4", "5", "6", "7", -- ASCII 48-55
- "8", "9", ":", ";", "<", "=", ">", "?", -- ASCII 56-63
- "@", "A", "B", "C", "D", "E", "F", "G", -- ASCII 64-71
- "H", "I", "J", "K", "L", "M", "N", "O", -- ASCII 72-79
- "P", "Q", "R", "S", "T", "U", "V", "W", -- ASCII 80-87
- "X", "Y", "Z", "[", "\\", "]", "^", "_", -- ASCII 88-95
- "`", "a", "b", "c", "d", "e", "f", "g", -- ASCII 96-103
- "h", "i", "j", "k", "l", "m", "n", "o", -- ASCII 104-111
- "p", "q", "r", "s", "t", "u", "v", "w", -- ASCII 112-119
- "x", "y", "z", "{", "|", "}", "~", "⌂", -- ASCII 120-127
- "Ç", "ü", "é", "â", "ä", "à", "å", "ç", -- 128-135 (dos code page 850)
- "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", -- 136-143
- "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", -- 144-151
- "ÿ", "Ö", "Ü", "ø", "£", "Ø", "×", "ƒ", -- 152-159
- "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", -- 160-167
- "¿", "®", "¬", "½", "¼", "¡", "«", "»", -- 168-175
- "░", "▒", "▓", "│", "┤", "Á", "Â", "À", -- 176-183
- "©", "╣", "║", "╗", "╝", "¢", "¥", "┐", -- 184-191
- "└", "┴", "┬", "├", "─", "┼", "ã", "Ã", -- 192-199
- "╚", "╔", "╩", "╦", "╠", "═", "╬", "¤", -- 200-207
- "ð", "Ð", "Ê", "Ë", "È", "ı", "Í", "Î", -- 208-215
- "Ï", "┘", "┌", "█", "▄", "¦", "Ì", "▀", -- 216-223
- "Ó", "ß", "Ô", "Ò", "õ", "Õ", "µ", "þ", -- 224-231
- "Þ", "Ú", "Û", "Ù", "ý", "Ý", "¯", "´", -- 232-239
- "≡", "±", "‗", "¾", "¶", "§", "÷", "¸", -- 240-247
- "°", "¨", "·", "¹", "³", "²", "■", "□", -- 248-255 (use empty box for 255)
- };
- htmlEscape[0] = "·" -- in this table, we use a 8 bit character set, where every has a different graphical representation
- -- the conversion table should work as a convertion function for strings as well
- setmetatable(htmlEscape, {__call = function (tab,str) return string.gsub(str, ".", function (c) return tab[c:byte()] end) end})
- function htmlEsc(txt)
- s = txt:gsub("%&", "&")
- s = s:gsub("%<", "<")
- return s:gsub("%>", ">")
- end
- function iso8859_1_to_utf8(txt)
- local s = txt:gsub(".",
- function (c)
- local b = c:byte()
- if b < 128 then
- return c
- elseif b < 192 then
- return string.char(194, b)
- else
- return string.char(195, b-64)
- end
- end)
- return s
- end
|