File tree Expand file tree Collapse file tree 1 file changed +4
-15
lines changed
Expand file tree Collapse file tree 1 file changed +4
-15
lines changed Original file line number Diff line number Diff line change 2626
2727local function escape (str )
2828 return str :gsub (" ." , function (char )
29- if char :match (" [^ %-~\n\t\a\b\v\r\"\' ]" ) then -- Check if non Printable ASCII Character
30- return string.format (" \\ %03d" , string.byte (char ))
29+ local byte = string.byte (char )
30+ if byte >= 32 and byte <= 126 and char ~= " \\ " and char ~= " \" " and char ~= " \' " then
31+ return char
3132 end
3233 if (char == " \\ " ) then
3334 return " \\\\ " ;
@@ -38,25 +39,13 @@ local function escape(str)
3839 if (char == " \r " ) then
3940 return " \\ r" ;
4041 end
41- if (char == " \t " ) then
42- return " \\ t" ;
43- end
44- if (char == " \a " ) then
45- return " \\ a" ;
46- end
47- if (char == " \b " ) then
48- return " \\ b" ;
49- end
50- if (char == " \v " ) then
51- return " \\ v" ;
52- end
5342 if (char == " \" " ) then
5443 return " \\\" " ;
5544 end
5645 if (char == " \' " ) then
5746 return " \\\' " ;
5847 end
59- return char ;
48+ return string.format ( " \\ %03d " , byte ) ;
6049 end )
6150end
6251
You can’t perform that action at this time.
0 commit comments