Re: Inconsistent handling of invalid escape sequences

Spar <[email protected]>
Newsgroups gmane.comp.lang.lua.general
Message-ID <c8d5f849-31a7-4774-9f47-cfc44dcf21d5@Spark>
You need to escape twice.
In the command line it interpreted as you type, but in load you wrapped string into a string. You need to escape the escape in order to preserve it in parsing.

"\\c" -> \c
'"\\c"' -> "\c"
'"\\\\c"' -> "\\c" -> \c
On 8 Aug 2026 at 15:10 +0300, 'Martin Eden' via lua-l <[email protected]>, wrote:
> Invalid characters after backslash are accepted in Lua command-line
> interpreter but rejected when compiling code:
>
>   Lua 5.5.1  Copyright (C) 1994-2026 Lua.org, PUC-Rio
>   > print('\\c')
>   \c
>   > load('print("\\c")')
>   nil [string "print("\c")"]:1: invalid escape sequence near '"\c'
>
> Is there official policy for them?
>
> -- Martin
>
> --
> You received this message because you are subscribed to the Google Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/063f43a8-5001-47dc-8337-d749193cb73a%40disroot.org.

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/c8d5f849-31a7-4774-9f47-cfc44dcf21d5%40Spark.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.