canon
Description:
For each character in string
, if the character is not in valid_chars
, replaces the character with substitutor
.
Modifies string
in place, and return string
itself, not a copy. The return value is to allow nesting such as: ```C
g_ascii_strup (g_strcanon (str, "abc", '?')) ```
In order to modify a copy, you may use [func@GLib.strdup]: ```C reformatted = g_strcanon (g_strdup (const_str), "abc", '?'); … g_free ( reformatted); ```
Example: Replace invalid chars:
public static int main (string[] args) {
string str = "glib-2.0";
// Output: ``?????2.0``
str.canon ("0123456789.", '?');
print ("%s\n", str);
return 0;
}
valac --pkg glib-2.0 string.canon.vala
Parameters:
valid_chars |
bytes permitted in |
substitutor |
replacement character for disallowed bytes |
string |
a nul-terminated array of bytes |
Returns:
the modified |