[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: persistent data & serialization
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 13 Nov 2000 10:58:08 -0200
> Comments, improvements and bug reports are welcome.
A simpler way to write 'escapestring':
escapetable = {
['\a'] = '\\a', ['\b'] = '\\b', ['\f'] = '\\f',
['\n'] = '\\n', ['\r'] = '\\r', ['\t'] = '\\t',
['\v'] = '\\v',
['"'] = '\\"', ["'"] = "\\'", ['\\'] = '\\\\',
}
function escapestring(s)
s = gsub(s,"([%c\\'\"%z])", function(l) -- convert special characters
return escapetable[l] or format("\\%03d", strbyte(l))
end)
return s
end
-- Roberto