escape
Description:
It replaces the following special characters in the string source with their corresponding C escape sequence:
| Symbol | Escape | |-----------------------------------------------------------------------------|--------| | U+0008 Backspace | `\b` | | U+000C Form Feed | `\f` | | U+000A Line Feed | `\n` | | U+000D Carriage Return | `\r` | | U+0009 Horizontal Tabulation | `\t` | | U+000B Vertical Tabulation | `\v` |
It also inserts a backslash (`\`) before any backslash or a double quote (`"`). Additionally all characters in the range 0x01-0x1F (everything
below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are replaced with a backslash followed by their octal representation. Characters
supplied in exceptions are not escaped.
[func@GLib.strcompress] does the reverse conversion.
Example: Escapes special characters:
public static int main () {
// Output:
// ``\tOh please, don't call me human.``
// ``\tJust \"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.".escape ("\n");
print ("%s\n", escaped);
return 0;
}
valac --pkg glib-2.0 string.escape.vala
Parameters:
| exceptions |
a string of characters not to escape in |
| source |
a string to escape |
Returns:
|
a newly-allocated copy of |