From http://www.jwz.org/xscreensaver/xscreensaver-5.31.tar.gz
[xscreensaver] / utils / utf8wc.h
1 /* xscreensaver, Copyright (c) 2014 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 #endif /* __XSCREENSAVER_UTF8WC_H__ */