mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
docs: Adjust gvariant-text-format reference on bytestring escapes
- Do not refer to people’s expectation, they can wildly differ. - Do not link to `strcompress`, that confusingly does not support `\a`. Link Wikipedia instead. - Reiterate the C escape sequences from string section, they are not that many. - Mention escaping newline and other characters (also copied from string section). - Mention Unicode escapes not being supported to contrast with strings.
This commit is contained in:
parent
32b8a8400d
commit
460a9c299c
@ -303,10 +303,15 @@ end with a `NUL` byte.
|
||||
Bytestrings are specified with either `b""` or `b''`. As with strings, there
|
||||
is no fundamental difference between the two different types of quotes.
|
||||
|
||||
Bytestrings support the full range of escapes that you would expect (ie:
|
||||
those supported by [`func@GLib.strcompress`]. This includes the normal control
|
||||
sequence escapes (as mentioned in the section on strings) as well as octal
|
||||
and hexadecimal escapes of the forms `\nnn` and `\xnn`.
|
||||
Like in strings, the [C-style control sequence escapes][C escape sequences]
|
||||
`\a`, `\b`, `\f`, `\n`, `\r`, `\t` and `\v` are supported. Similarly,
|
||||
a `\` before a newline character causes the newline to be ignored.
|
||||
Unlike in strings, you can use octal and hexadecimal escapes
|
||||
of the forms `\nnn` and `\xnn`. Finally, any other character following `\`
|
||||
is copied literally (for example, `\"` or `\\`) but for forwards compatibility
|
||||
with future additions you should only use this feature when necessary
|
||||
for escaping backslashes or quotes. Unlike in strings, Unicode escapes
|
||||
are not supported.
|
||||
|
||||
`b'abc'` is equivalent to `[byte 0x61, 0x62, 0x63, 0]`.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user