diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-18 10:35:32 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-20 12:05:45 +0200 |
| commit | 38f00e3e8a50e1690dcb78cf1eca8b6befb7173b (patch) | |
| tree | f613eec7ee39a312229e97d22557623ef7a2510f /libutf.h | |
| parent | 0fa9885cda0778467ca5737ac888ece5ef371b3d (diff) | |
| download | vis-38f00e3e8a50e1690dcb78cf1eca8b6befb7173b.tar.gz vis-38f00e3e8a50e1690dcb78cf1eca8b6befb7173b.tar.xz | |
vis: improve insertion of verbatim characters via CTRL-V in insert mode
Recognized formats are:
CTRL-V nnn decimal value nnn
CTRL-V onnn or CTRL-V Onnn octal value nnn
CTRL-V xnn or CTRL-V Xnn hex value nn
CTRL-V unnnn Unicode codepoint nnnn
CTRL-V Unnnnnnnn Unicode codepoint nnnnnnnn
Leading zeros can be omitted, any illegal character for the given
format will be ignored and terminates the numerical code.
Diffstat (limited to 'libutf.h')
| -rw-r--r-- | libutf.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libutf.h b/libutf.h new file mode 100644 index 0000000..4d3f91c --- /dev/null +++ b/libutf.h @@ -0,0 +1,34 @@ +#ifndef LIBUTF_H +#define LIBUTF_H + +/* libutf8 © 2012-2015 Connor Lane Smith <cls@lubutu.com> */ +#include <stddef.h> +#include <stdint.h> + +#if __STDC_VERSION__ >= 201112L +#include <uchar.h> +#ifdef __STDC_UTF_32__ +#define RUNE_C INT32_C +typedef char32_t Rune; +#endif +#endif + +#ifndef RUNE_C +#ifdef INT32_C +#define RUNE_C INT32_C +typedef uint_least32_t Rune; +#else +#define RUNE_C(x) x##L +typedef unsigned long Rune; +#endif +#endif + +#define UTFmax 6 /* maximum bytes per rune */ + +#define Runeself 0x80 /* rune and utf are equal (<) */ +#define Runemax RUNE_C(0x10FFFF) /* maximum rune value */ + +int runelen(Rune r); +int runetochar(char *s, const Rune *p); + +#endif |
