1
/* $Id: unicode.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PJ_UNICODE_H__
21
#define __PJ_UNICODE_H__
27
* @defgroup PJ_UNICODE Unicode Support
37
* @brief Provides Unicode conversion for Unicode OSes
41
* Convert ANSI strings to Unicode strings.
43
* @param str The ANSI string to be converted.
44
* @param len The length of the input string.
45
* @param wbuf Buffer to hold the Unicode string output.
46
* @param wbuf_count Buffer size, in number of elements (not bytes).
48
* @return The Unicode string, NULL terminated.
50
PJ_DECL(wchar_t*) pj_ansi_to_unicode(const char *str, pj_size_t len,
51
wchar_t *wbuf, pj_size_t wbuf_count);
55
* Convert Unicode string to ANSI string.
57
* @param wstr The Unicode string to be converted.
58
* @param len The length of the input string.
59
* @param buf Buffer to hold the ANSI string output.
60
* @param buf_size Size of the output buffer.
62
* @return The ANSI string, NULL terminated.
64
PJ_DECL(char*) pj_unicode_to_ansi(const wchar_t *wstr, pj_size_t len,
65
char *buf, pj_size_t buf_size);
68
#if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
71
* This macro is used to declare temporary Unicode buffer for ANSI to
72
* Unicode conversion, and should be put in declaration section of a block.
73
* When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this
74
* macro will expand to nothing.
76
# define PJ_DECL_UNICODE_TEMP_BUF(buf,size) wchar_t buf[size];
79
* This macro will convert ANSI string to native, when the platform's
80
* native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).
82
# define PJ_STRING_TO_NATIVE(s,buf,max) pj_ansi_to_unicode( \
87
* This macro is used to declare temporary ANSI buffer for Unicode to
88
* ANSI conversion, and should be put in declaration section of a block.
89
* When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this
90
* macro will expand to nothing.
92
# define PJ_DECL_ANSI_TEMP_BUF(buf,size) char buf[size];
96
* This macro will convert Unicode string to ANSI, when the platform's
97
* native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).
99
# define PJ_NATIVE_TO_STRING(cs,buf,max) pj_unicode_to_ansi( \
106
* This macro is used to declare temporary Unicode buffer for ANSI to
107
* Unicode conversion, and should be put in declaration section of a block.
108
* When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this
109
* macro will expand to nothing.
111
# define PJ_DECL_UNICODE_TEMP_BUF(var,size)
113
* This macro will convert ANSI string to native, when the platform's
114
* native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).
116
# define PJ_STRING_TO_NATIVE(s,buf,max) ((char*)s)
118
* This macro is used to declare temporary ANSI buffer for Unicode to
119
* ANSI conversion, and should be put in declaration section of a block.
120
* When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this
121
* macro will expand to nothing.
123
# define PJ_DECL_ANSI_TEMP_BUF(buf,size)
125
* This macro will convert Unicode string to ANSI, when the platform's
126
* native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).
128
# define PJ_NATIVE_TO_STRING(cs,buf,max) ((char*)(const char*)cs)
141
#endif /* __PJ_UNICODE_H__ */