diff options
author | Simon Rettberg | 2018-10-16 10:08:48 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-10-16 10:08:48 +0200 |
commit | d3a98cf6cbc3bd0b9efc570f58e8812c03931c18 (patch) | |
tree | cbddf8e50f35a9c6e878a5bfe3c6d625d99e12ba /utils/utf8wc.h | |
download | xscreensaver-d3a98cf6cbc3bd0b9efc570f58e8812c03931c18.tar.gz xscreensaver-d3a98cf6cbc3bd0b9efc570f58e8812c03931c18.tar.xz xscreensaver-d3a98cf6cbc3bd0b9efc570f58e8812c03931c18.zip |
Original 5.40
Diffstat (limited to 'utils/utf8wc.h')
-rw-r--r-- | utils/utf8wc.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/utils/utf8wc.h b/utils/utf8wc.h new file mode 100644 index 0000000..d91567c --- /dev/null +++ b/utils/utf8wc.h @@ -0,0 +1,47 @@ +/* xscreensaver, Copyright (c) 2014-2015 Jamie Zawinski <jwz@jwz.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __XSCREENSAVER_UTF8WC_H__ +#define __XSCREENSAVER_UTF8WC_H__ + +/* Utilities for converting between UTF8 and XChar2b. */ + +/* Converts a null-terminated UTF8 string to a null-terminated XChar2b array. + This only handles characters that can be represented in 16 bits, the + Basic Multilingual Plane. (No hieroglyphics, Elvish, Klingon or Emoji.) + */ +extern XChar2b * utf8_to_XChar2b (const char *, int *length_ret); + +/* Converts a null-terminated XChar2b array to a null-terminated UTF8 string. + */ +extern char * XChar2b_to_utf8 (const XChar2b *, int *length_ret); + +/* Split a UTF8 string into an array of strings, one per character. + The sub-strings will be null terminated and may be multiple bytes. + */ +extern char ** utf8_split (const char *string, int *length_ret); + +/* Converts a UTF8 string to the closest Latin1 or ASCII equivalent. + */ +extern char *utf8_to_latin1 (const char *string, Bool ascii_p); + +/* Converts a Unicode character to a multi-byte UTF8 sequence. + Returns the number of bytes written. + */ +extern int utf8_encode (unsigned long uc, char *out, long length); + +/* Parse the first UTF8 character at the front of the string. + Return the Unicode character, and the number of bytes read. + */ +extern long utf8_decode (const unsigned char *in, long length, + unsigned long *unicode_ret); + +#endif /* __XSCREENSAVER_UTF8WC_H__ */ |