PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: TyShkan on 11 November, 2004, 12:39:46

Title: Alt functions
Post by: TyShkan on 11 November, 2004, 12:39:46
I have one trouble, i need php's "addslashes" in lua. Have the Lua such function? Or who have the script, that doing this?

Ps: Sorry for my english ;)
Title:
Post by: Herodes on 11 November, 2004, 13:27:01
what does it do ?
Title:
Post by: TyShkan on 11 November, 2004, 19:58:56
QuoteReturns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).

 ;)
Title:
Post by: bastya_elvtars on 11 November, 2004, 20:50:55
QuoteOriginally posted by TyShkan
QuoteReturns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).

 ;)

QuoteStrings in Lua can contain the
following C-like escape sequences:
\a bell
\b back space
\f form feed
\n newline
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\" double quote
\? single quote
Title:
Post by: Herodes on 11 November, 2004, 22:21:48
maybe this will do .. ( not tested at all .. )
function addEscapes(str)
local t = {
[1] = "\"",
[2] = "'",
[3] = "\\"
}
for i , v in t do
if strfind(str, v) then
str = gsub(str, v, "\\"..v)
end
end
return str
end