Update syntax.md

Fix hexadecimal escape sequences
This commit is contained in:
Arseny Kapoulkine 2020-06-24 12:20:58 -07:00 committed by GitHub
parent 2cd63aa589
commit 053061e3e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,7 @@ end
Note that future versions of Lua extend the Lua 5.1 syntax with the following features; with the exception of the string literals, these are **not** supported by Luau: Note that future versions of Lua extend the Lua 5.1 syntax with the following features; with the exception of the string literals, these are **not** supported by Luau:
- hexadecimal (`\0x`), Unicode (`\u`) and `\z` escapes for string literals - hexadecimal (`\x`), Unicode (`\u`) and `\z` escapes for string literals
- goto statements and labels - goto statements and labels
- bitwise operators - bitwise operators
- floor division operator (`//`) - floor division operator (`//`)
@ -33,7 +33,7 @@ The rest of this document documents additional syntax used in Luau.
As noted above, Luau implements support for hexadecimal (`\0x`), Unicode (`\u`) and `\z` escapes for string literals. This syntax follows [Lua 5.3 syntax](https://www.lua.org/manual/5.3/manual.html#3.1): As noted above, Luau implements support for hexadecimal (`\0x`), Unicode (`\u`) and `\z` escapes for string literals. This syntax follows [Lua 5.3 syntax](https://www.lua.org/manual/5.3/manual.html#3.1):
- `\0xAB` inserts a character with the code 0xAB into the string - `\xAB` inserts a character with the code 0xAB into the string
- `\u{ABC}` inserts a UTF8 byte sequence that encodes U+0ABC character into the string (note that braces are mandatory) - `\u{ABC}` inserts a UTF8 byte sequence that encodes U+0ABC character into the string (note that braces are mandatory)
- `\z` at the end of the line inside a string literal ignores all following whitespace including newlines, which can be helpful for breaking long literals into multiple lines. - `\z` at the end of the line inside a string literal ignores all following whitespace including newlines, which can be helpful for breaking long literals into multiple lines.