compress
Description:
Makes a copy of a string replacing C string-style escape sequences with their one byte equivalent:
- `\b` → U+0008 Backspace
- `\f` → U+000C Form Feed
- `\n` → U+000A Line Feed
- `\r` → U+000D Carriage Return
- `\t` → U+0009 Horizontal Tabulation
- `\v` → U+000B Vertical Tabulation
- `\` followed by one to three octal digits → the numeric value (mod 256)
- `\` 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.
Example: Unescape special characters:
public static int main () {
// Output:
// `` Oh please, don't call me human.``
// `` Just "Doctor" would do very nicely, thank you.``
string escaped = "\\tOh please, don't call me human.\\n\\tJust \\\"Doctor\\\" would do very nicely, thank you.".compress ();
print ("%s\n", escaped);
return 0;
}
valac --pkg glib-2.0 string.compress.vala
Parameters:
| source |
a string to compress |
Returns:
|
a newly-allocated copy of |