~sircmpwn/scdoc

ref: 9f74b6a0bf9794081b755274bbddd15deb6a10aa scdoc/src/utf8_chsize.c -rw-r--r-- 220 bytes
9f74b6a0Drew DeVault Parse section headings 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdint.h>
#include <stddef.h>
#include "unicode.h"

size_t utf8_chsize(uint32_t ch) {
	if (ch < 0x80) {
		return 1;
	} else if (ch < 0x800) {
		return 2;
	} else if (ch < 0x10000) {
		return 3;
	}
	return 4;
}