Added extra encoded character support (#2050)

This commit is contained in:
Eduardo Quezada 2024-11-24 22:46:01 -03:00 committed by GitHub
parent 6560bbab21
commit 4beb0efbcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,6 +86,8 @@ static inline char mini_pchar_decode(char encoded)
ret = '('; // opening parentheses ret = '('; // opening parentheses
else if (encoded == CHAR_RIGHT_PAREN) else if (encoded == CHAR_RIGHT_PAREN)
ret = ')'; // closing parentheses ret = ')'; // closing parentheses
else if (encoded == CHAR_HYPHEN)
ret = '-'; // hyphen
return ret; return ret;
} }
@ -133,7 +135,31 @@ static s32 _putsEncoded(char *s, s32 len, void *buf)
{ {
break; break;
} }
*(b->pbuffer ++) = mini_pchar_decode(s[i]); if (s[i] == CHAR_NEWLINE)
{
*(b->pbuffer ++) = '\\';
*(b->pbuffer ++) = 'n';
}
else if (s[i] == CHAR_PROMPT_SCROLL)
{
*(b->pbuffer ++) = '\\';
*(b->pbuffer ++) = 'l';
}
else if (s[i] == CHAR_PROMPT_CLEAR)
{
*(b->pbuffer ++) = '\\';
*(b->pbuffer ++) = 'p';
}
else if (s[i] == CHAR_ELLIPSIS)
{
*(b->pbuffer ++) = '.';
*(b->pbuffer ++) = '.';
*(b->pbuffer ++) = '.';
}
else
{
*(b->pbuffer ++) = mini_pchar_decode(s[i]);
}
} }
*(b->pbuffer) = 0; *(b->pbuffer) = 0;
return b->pbuffer - p0; return b->pbuffer - p0;