File tree Expand file tree Collapse file tree 1 file changed +6
-15
lines changed
Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -22,19 +22,14 @@ local function unlookupify(tb)
2222 return tb2 ;
2323end
2424
25-
26- local InvalidStringCharsMatch = " [^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ %+%/!?%_-=,\n\r\t\a\b\v\\\"\' %.:;%&/()%%%[%]%*%^]"
2725local function escape (str )
28- if (string.match (str , InvalidStringCharsMatch )) then
29- local ret = " " ;
30- local bytes = {string.byte (str , 1 , - 1 )};
31- for i , byte in ipairs (bytes ) do
32- ret = ret .. string.format (" \\ %03d" , byte );
33- end
34- return ret ;
35- end
36-
3726 return str :gsub (" ." , function (char )
27+ if char :match (' [^ -~\n\t\a\b\v\r\"\' ]' ) then -- Check if non Printable Ascii Character
28+ return string.format (" \\ %03d" , string.byte (char ))
29+ end
30+ if (char == " \\ " ) then
31+ return " \\\\ " ;
32+ end
3833 if (char == " \n " ) then
3934 return " \\ n" ;
4035 end
@@ -53,16 +48,12 @@ local function escape(str)
5348 if (char == " \v " ) then
5449 return " \\ v" ;
5550 end
56- if (char == " \\ " ) then
57- return " \\\\ " ;
58- end
5951 if (char == " \" " ) then
6052 return " \\\" " ;
6153 end
6254 if (char == " \' " ) then
6355 return " \\\' " ;
6456 end
65-
6657 return char ;
6758 end )
6859end
You can’t perform that action at this time.
0 commit comments