vim-patch:8.2.3522: cannot use \x and \u when setting 'listchars' (#16049)

Problem:    Cannot use \x and \u when setting 'listchars'.
Solution:   Support hex and unicode in hex form. (closes vim/vim#9006)
93ff6720fe
This commit is contained in:
zeertzjq
2021-11-18 09:55:59 +08:00
committed by GitHub
parent eb3d59126e
commit 5ff972cafe
4 changed files with 61 additions and 15 deletions

View File

@@ -1642,6 +1642,16 @@ int hex2nr(int c)
return c - '0';
}
/// Convert two hex characters to a byte.
/// Return -1 if one of the characters is not hex.
int hexhex2nr(char_u *p)
{
if (!ascii_isxdigit(p[0]) || !ascii_isxdigit(p[1])) {
return -1;
}
return (hex2nr(p[0]) << 4) + hex2nr(p[1]);
}
/// Check that "str" starts with a backslash that should be removed.
/// For Windows this is only done when the character after the
/// backslash is not a normal file name character.