Commit | Line | Data |
---|---|---|
3144ee8a AT |
1 | /* xscreensaver, Copyright (c) 2014-2015 Jamie Zawinski <jwz@jwz.org> |
2 | * | |
3 | * Permission to use, copy, modify, distribute, and sell this software and its | |
4 | * documentation for any purpose is hereby granted without fee, provided that | |
5 | * the above copyright notice appear in all copies and that both that | |
6 | * copyright notice and this permission notice appear in supporting | |
7 | * documentation. No representations are made about the suitability of this | |
8 | * software for any purpose. It is provided "as is" without express or | |
9 | * implied warranty. | |
10 | */ | |
11 | ||
12 | #ifndef __XSCREENSAVER_UTF8WC_H__ | |
13 | #define __XSCREENSAVER_UTF8WC_H__ | |
14 | ||
15 | /* Utilities for converting between UTF8 and XChar2b. */ | |
16 | ||
17 | /* Converts a null-terminated UTF8 string to a null-terminated XChar2b array. | |
18 | This only handles characters that can be represented in 16 bits, the | |
19 | Basic Multilingual Plane. (No hieroglyphics, Elvish, Klingon or Emoji.) | |
20 | */ | |
21 | extern XChar2b * utf8_to_XChar2b (const char *, int *length_ret); | |
22 | ||
23 | /* Converts a null-terminated XChar2b array to a null-terminated UTF8 string. | |
24 | */ | |
25 | extern char * XChar2b_to_utf8 (const XChar2b *, int *length_ret); | |
26 | ||
27 | /* Split a UTF8 string into an array of strings, one per character. | |
28 | The sub-strings will be null terminated and may be multiple bytes. | |
29 | */ | |
30 | extern char ** utf8_split (const char *string, int *length_ret); | |
31 | ||
32 | /* Converts a UTF8 string to the closest Latin1 or ASCII equivalent. | |
33 | */ | |
34 | extern char *utf8_to_latin1 (const char *string, Bool ascii_p); | |
35 | ||
36 | /* Converts a Unicode character to a multi-byte UTF8 sequence. | |
37 | Returns the number of bytes written. | |
38 | */ | |
39 | extern int utf8_encode (unsigned long uc, char *out, long length); | |
40 | ||
41 | /* Parse the first UTF8 character at the front of the string. | |
42 | Return the Unicode character, and the number of bytes read. | |
43 | */ | |
44 | extern long utf8_decode (const unsigned char *in, long length, | |
45 | unsigned long *unicode_ret); | |
46 | ||
47 | #endif /* __XSCREENSAVER_UTF8WC_H__ */ |