Open
Description
Libc provides the sscanf
(and family) to parse a string from a format to some variables. Basically the exact opposite of printf
.
As we have the C3 version of printf
, it would also be great to have a C3 version of sscanf
.
Example:
fn void main() {
String seq = "\e[97;5u";
int codepoint;
int modifier;
if (string::sscanf(seq, "\e[%d;%du", &codepoint, &modifier) == 2) {
io::printfn("Parsed codepoint %d and modifier %d", codepoint, modifier);
} else {
io::eprintn("Failed to parse string");
}
}