This script is a tutorial script: it shows the possible caveats of the 'non-long' declaration and hopefully teaches coders to play safe when needed. I used dofile on files, cause string.find returns strings as if they were long ones.
I hope you can benefit from it.
By the way, this is a result of a discussion on the luahub between GeceBekcisi, Mutor and me.
str=[[\tight]] -- This is a long string, \t would become a tab char if used between "
_,_,str2=string.find(str,"(.+)") -- let's get all of the string. Looks stupid, but shows that string.find returns it as a long string.
local file=os.tmpname() -- Let's generate a tempfile.
f=io.open(file,"w+")
f:write("str3=\""..str2.."\"") -- We write it out: str3="\tight"
f:close()
dofile(file) -- We load it.
print(str3) -- We print it.
f=io.open(file,"w+")
f:write("str3="..string.format("%q",str2)) -- Formatting this way will result in: str3="\\tight"
f:close()
dofile(file)
print(str2)
os.remove(file) -- Let's delete the tempfile.