11#ifndef __UNICODEUTIL_H__
12#define __UNICODEUTIL_H__
32#define DEBUG_UTF_8_ENABLED true
34#define DEBUG_UTF_8_ENABLED false
37#define _CHECK_UTF_8(level, str, len) \
39 const char *__uni_endptr; \
40 if (DEBUG_UTF_8_ENABLED && (str) != NULL && \
41 !g_utf8_validate(str, len, &__uni_endptr)) { \
42 ws_log_utf8(str, len, __uni_endptr); \
46#define WS_UTF_8_CHECK(str, len) \
47 _CHECK_UTF_8(LOG_LEVEL_DEBUG, str, len)
49#define WS_UTF_8_DEBUG_HERE(str, len) \
50 _CHECK_UTF_8(LOG_LEVEL_ECHO, str, len)
53const int ws_utf8_seqlen[256];
60#define ws_utf8_char_len(ch) (ws_utf8_seqlen[(ch)])
70WS_DLL_PUBLIC uint8_t *
71ws_utf8_make_valid(
wmem_allocator_t *scope,
const uint8_t *ptr, ssize_t length);
77ws_utf8_make_valid_strbuf(
wmem_allocator_t *scope,
const uint8_t *ptr, ssize_t length);
89const wchar_t * utf_8to16(
const char *utf8str);
98void utf_8to16_snprintf(TCHAR *utf16buf,
int utf16buf_len,
const char* fmt, ...)
109char * utf_16to8(const
wchar_t *utf16str);
119char **arg_list_utf_16to8(
int argc,
wchar_t *wc_argv[]);
127#define IS_LEAD_SURROGATE(uchar2) \
128 ((uchar2) >= 0xd800 && (uchar2) < 0xdc00)
129#define IS_TRAIL_SURROGATE(uchar2) \
130 ((uchar2) >= 0xdc00 && (uchar2) < 0xe000)
131#define SURROGATE_VALUE(lead, trail) \
132 (((((lead) - 0xd800) << 10) | ((trail) - 0xdc00)) + 0x10000)
Definition wmem_allocator.h:27
Definition wmem_strbuf.h:42