From 460a9c299c40429916dea62b3d0dd8d19c74163a Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 19 May 2024 00:54:12 +0200 Subject: [PATCH] docs: Adjust gvariant-text-format reference on bytestring escapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- docs/reference/glib/gvariant-text-format.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/reference/glib/gvariant-text-format.md b/docs/reference/glib/gvariant-text-format.md index 8365c1f33..d3adb2088 100644 --- a/docs/reference/glib/gvariant-text-format.md +++ b/docs/reference/glib/gvariant-text-format.md @@ -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]`.