Lindenii Project Forge
Login

scdoc

scdoc mirror for performance testing

Warning: Due to various recent migrations, viewing non-HEAD refs may be broken.

/src/utf8_chsize.c (raw)

#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;
}