#!Lua-5.0.exe -- Win2Dos.lua -- Convert Win Ansi chars to MS-Dos chars and back. -- by Philippe Lhoste http://Phi.Lho.free.fr -- v. 1.0 -- 2004/02/25 -- Creation local win2dosChars = { [''] = '', -- à [''] = '', -- â [''] = '', -- æ [''] = '', -- ç [''] = '', -- é [''] = '', -- è [''] = '', -- ê [''] = '', -- ë [''] = '', -- î [''] = '', -- ï [''] = '', -- ô [''] = '', -- ö -- [''] = '', -- œ [''] = '', -- ù [''] = '', -- û [''] = '', -- ÿ [''] = '', -- À [''] = '', --  [''] = '', -- Æ [''] = '', -- Ç [''] = '', -- É [''] = '', -- È [''] = '', -- Ê [''] = '', -- Ë [''] = '', -- Î [''] = '', -- Ï [''] = '', -- Ô [''] = '', -- Ö -- [''] = '', -- Œ [''] = '', -- Ù [''] = '', -- Û [''] = '', -- Ÿ [''] = '', -- « [''] = '', -- » [''] = '', -- © -- [''] = '', -- ® -- -- } -- Invert table for reverse conversion local dos2winChars = {} for k, v in pairs(win2dosChars) do dos2winChars[v] = k end local toConvertWin2Dos = "([" -- Add all characters to encode to the pattern string for charWin, charDos in pairs(win2dosChars) do toConvertWin2Dos = toConvertWin2Dos .. charWin end toConvertWin2Dos = toConvertWin2Dos .. "])" local toConvertDos2Win = "([" -- Add all characters to encode to the pattern string for charWin, charDos in pairs(dos2winChars) do toConvertDos2Win = toConvertDos2Win .. charWin end toConvertDos2Win = toConvertDos2Win .. "])" function EncodeWin2Dos(toEncode) if toEncode == nil or type(toEncode) ~= "string" then return '' end return (string.gsub(toEncode, toConvertWin2Dos, function (char) return win2dosChars[char] or char end)) end function EncodeDos2Win(toEncode) if toEncode == nil or type(toEncode) ~= "string" then return '' end return (string.gsub(toEncode, toConvertDos2Win, function (char) return dos2winChars[char] or char end)) end