diff options
Diffstat (limited to 'src/nvim/charset.c')
-rw-r--r-- | src/nvim/charset.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 5e18f9d86e..eb0903b594 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -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. |