aboutsummaryrefslogtreecommitdiff
path: root/include/libunicode.h
blob: e017ac5e36e26996ffb3c09fd8e84932bb9ec5e6 (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
#pragma once

typedef uint32 rune;

/* 
 * We have to use the preprocessor to ensure
 * we have unsigned constants. Unfortunate...
 */

#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);
int     utf8·runelen(rune r);

int     utf8·fullrune(char *s, int n);
char   *utf8·findrune(char *s, long i);
char   *utf8·findrrune(char* s, long c);
int     utf8·bytetorune(rune *r, char *s);
int     utf8·runetobyte(char *s, rune *r);

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);