docs: Describe g_strcompress processing

GVariant Text Format section on bytestrings links to `g_strcompress`
but what it does was only briefly described in the header file,
which is not visible in the gi-docgen-built reference. To really
find out one would have to guess to continue through the rabbit hole
to `g_strescape`.

Let’s merge the description from the header and elaborate on it a bit.
This commit is contained in:
Jan Tojnar 2024-05-18 23:09:23 +02:00
parent 4acedc8669
commit c167562b38
2 changed files with 13 additions and 6 deletions

View File

@ -2109,9 +2109,20 @@ g_strcanon (gchar *string,
* g_strcompress:
* @source: a string to compress
*
* Replaces all escaped characters with their one byte equivalent.
* Makes a copy of a string replacing C string-style escape
* sequences with their one byte equivalent:
*
* This function does the reverse conversion of [func@GLib.strescape].
* - `\b` [U+0008 Backspace](https://en.wikipedia.org/wiki/Backspace)
* - `\f` [U+000C Form Feed](https://en.wikipedia.org/wiki/Form_feed)
* - `\n` [U+000A Line Feed](https://en.wikipedia.org/wiki/Newline)
* - `\r` [U+000D Carriage Return](https://en.wikipedia.org/wiki/Carriage_return)
* - `\t` [U+0009 Horizontal Tabulation](https://en.wikipedia.org/wiki/Tab_character)
* - `\v` [U+000B Vertical Tabulation](https://en.wikipedia.org/wiki/Vertical_Tab)
* - `\` followed by one to three octal digits the numeric value (mod 255)
* - `\` followed by any other character the character as is.
* For example, `\\` will turn into a backslash (`\`) and `\"` into a double quote (`"`).
*
* [func@GLib.strescape] does the reverse conversion.
*
* Returns: a newly-allocated copy of @source with all escaped
* character compressed

View File

@ -327,10 +327,6 @@ g_strdup_inline (const char *str)
#endif /* !defined (__GTK_DOC_IGNORE__) */
#endif /* G_GNUC_CHECK_VERSION (2, 0) */
/* Make a copy of a string interpreting C string -style escape
* sequences. Inverse of g_strescape. The recognized sequences are \b
* \f \n \r \t \\ \" and the octal format.
*/
GLIB_AVAILABLE_IN_ALL
gchar* g_strcompress (const gchar *source) G_GNUC_MALLOC;