blob: 06ff8f03eb4d281c40ad583051fa70cdf21f88b5 [file] [log] [blame]
Ian Hodson2ee91b42012-05-14 12:29:36 +01001/*
2 * The authors of this software are Rob Pike and Ken Thompson.
3 * Copyright (c) 2002 by Lucent Technologies.
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose without fee is hereby granted, provided that this entire notice
6 * is included in all copies of any software which is or includes a copy
7 * or modification of this software and in all copies of the supporting
8 * documentation for such software.
9 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
10 * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
11 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
12 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
13 *
14 * This file and rune.cc have been converted to compile as C++ code
15 * in name space re2.
16 */
17#ifndef RE2_UTIL_UTF_H__
18#define RE2_UTIL_UTF_H__
19
20#include <stdint.h>
21
22namespace re2 {
23
24typedef signed int Rune; /* Code-point values in Unicode 4.0 are 21 bits wide.*/
25
26enum
27{
28 UTFmax = 4, /* maximum bytes per rune */
29 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
30 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
31 Runeerror = 0xFFFD, /* decoding error in UTF */
32 Runemax = 0x10FFFF, /* maximum rune value */
33};
34
35int runetochar(char* s, const Rune* r);
36int chartorune(Rune* r, const char* s);
37int fullrune(const char* s, int n);
38int utflen(const char* s);
39char* utfrune(const char*, Rune);
40
41} // namespace re2
42
43#endif // RE2_UTIL_UTF_H__