libt3window
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules
utf8.h
1 /* Copyright (C) 2011 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_UTF8_H
15 #define T3_UTF8_H
16 
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <unictype.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <t3window/window_api.h>
29 
32 #define T3_UTF8_CONTROL_MASK (UC_CATEGORY_MASK_Cs | UC_CATEGORY_MASK_Cf | UC_CATEGORY_MASK_Co | \
33  UC_CATEGORY_MASK_Cc | UC_CATEGORY_MASK_Zl | UC_CATEGORY_MASK_Zp)
34 
35 T3_WINDOW_API uint32_t t3_utf8_get(const char *src, size_t *size);
36 T3_WINDOW_API size_t t3_utf8_put(uint32_t c, char *dst);
37 
38 T3_WINDOW_API int t3_utf8_wcwidth(uint32_t c);
39 
41 #ifdef __cplusplus
42 } /* extern "C" */
43 #endif
44 #endif
size_t t3_utf8_put(uint32_t c, char *dst)
Convert a codepoint to a UTF-8 string.
Definition: utf8.c:126
int t3_utf8_wcwidth(uint32_t c)
Get the width of a Unicode codepoint.
Definition: utf8.c:160
uint32_t t3_utf8_get(const char *src, size_t *size)
Get the first codepoint represented by a UTF-8 string.
Definition: utf8.c:25