Skip to content
ZstrProcessEscape

ZstrProcessEscape

Description

Decode one escape sequence starting at *str. *str must point at the leading \\; on success the pointer is advanced past the consumed escape. Handles single-character escapes (\\n/\\r/\\t/\\b/\\f/\\v/\\a/\\\\/\\"/\\'/\\0), hex escapes (\\xNN), and \\u{...} Unicode escapes that fit in a single byte.

Parameters

Name Direction Description
str in,out Address of a Zstr cursor. Advanced past the consumed escape on success.

Success

Returns the decoded byte; *str is advanced past the escape.

Failure

Returns 0; logs the malformed escape; *str may have been partially advanced.

Usage example (Cross-references)

Usage examples (Cross-references)
    #endif // FEATURE_FLOAT
    
    char ZstrProcessEscape(Zstr *str) {
        if (!str || !*str)
            return 0;
        Zstr s = *str;
        if (*s != '\\') {
            LOG_ERROR("ZstrProcessEscape called on non-escape sequence");
            return 0;
        }
                if (*i == '\\') {
                    const char *curr = i;
                    char        c    = ZstrProcessEscape(&curr);
                    if (c == 0) { // Error in escape sequence
                        StrDeinit(s);
                if (*i == '\\') {
                    const char *curr = i;
                    char        c    = ZstrProcessEscape(&curr);
                    if (c == 0) { // Error in escape sequence
                        StrDeinit(s);
Last updated on