1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-06-13 14:50:41 +00:00
uemacs/utf8.h
Linus Torvalds 6b793211c2 Make cursor movement (largely) understand UTF-8 character boundaries
Ok, so it may do odd things if it's not truly utf-8, and when moving up
and down lines that have utf-8 the cursor moves oddly (because the byte
offset within the line stays constant, rather than the character
offset), but with this you can actually open the UTF8 example file and
move around it, and at least some of the movement makes sense.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-07-10 16:40:36 -07:00

15 lines
296 B
C

#ifndef UTF8_H
#define UTF8_H
typedef unsigned int unicode_t;
unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *res);
unsigned unicode_to_utf8(unsigned int c, char *utf8);
static inline int is_beginning_utf8(unsigned char c)
{
return (c & 0xc0) != 0x80;
}
#endif