Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions XUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,20 @@ static inline bool Char_isControl(char c) {
return (unsigned char)c < ' ' || c == '\x7F';
}

/* Replace control characters (C0 and DEL) with a safe substitute. */
static inline bool Char_isC1Control(char c, char next) {
return (unsigned char)c == 0xC2 && (unsigned char)next >= 0x80 && (unsigned char)next <= 0x9F;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

/* Replace control characters (C0, DEL, and C1) with a safe substitute. */
ATTR_NONNULL
static inline void String_stripControlChars(char* s) {
for (; *s; s++) {
if (Char_isControl(*s))
*s = '?';
for (; s[0]; s++) {
if (Char_isControl(s[0])) {
s[0] = '?';
} else if (Char_isC1Control(s[0], s[1])) {
s[0] = s[1] = '?';
s++;
}
}
}

Expand Down
Loading