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:
Jan Tojnar 2024-05-19 00:54:12 +02:00
parent 32b8a8400d
commit 460a9c299c

View File

@ -303,10 +303,15 @@ end with a `NUL` byte.
Bytestrings are specified with either `b""` or `b''`. As with strings, there Bytestrings are specified with either `b""` or `b''`. As with strings, there
is no fundamental difference between the two different types of quotes. is no fundamental difference between the two different types of quotes.
Bytestrings support the full range of escapes that you would expect (ie: Like in strings, the [C-style control sequence escapes][C escape sequences]
those supported by [`func@GLib.strcompress`]. This includes the normal control `\a`, `\b`, `\f`, `\n`, `\r`, `\t` and `\v` are supported. Similarly,
sequence escapes (as mentioned in the section on strings) as well as octal a `\` before a newline character causes the newline to be ignored.
and hexadecimal escapes of the forms `\nnn` and `\xnn`. 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]`. `b'abc'` is equivalent to `[byte 0x61, 0x62, 0x63, 0]`.