blob: 5e69fd182706e6070ff35d77892f94fba0b6f4df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#pragma once
typedef uint32 rune;
/*
* we have to use the preprocessor to ensure we have unsigned constants.
*/
#define UTFmax 4
#define RuneSync 0x80u
#define RuneSelf 0x80u
#define RuneErr 0xFFFDu
#define RuneMax 0x10FFFFu
#define RuneMask 0x1FFFFFu
/*
* UTF-8 functions.
*/
int utf8·len(char *s); // returns number of runes
int utf8·runelen(rune r); // returns number of bytes for rune
int utf8·decode(char *, rune *); // decode 1 rune from char stream, store into rune, return number of bytes
int utf8·encode(rune *, char *); // encode 1 rune from rune stream, store into char, return number of bytes
char *utf8·find(char *s, rune); // find rune in char stream
char *utf8·findlast(char* s, rune); // find last rune in char stream
int utf8·canfit(char *, int); // XXX: odd function...
int utf8·isletter(rune r);
int utf8·isdigit(rune r);
int utf8·isspace(rune r);
int utf8·istitle(rune r);
rune utf8·toupper(rune r);
rune utf8·tolower(rune r);
rune utf8·totitle(rune r);
|