Debian Codegraph @

Xpjproject/pjlib/include/pj/unicode.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef __PJ_UNICODE_H__
20 #define __PJ_UNICODE_H__
21
22 #include <pj/types.h>
23
24
25 /**
26 * @defgroup PJ_UNICODE Unicode Support
27 * @ingroup PJ_MISC
28 * @{
29 */
30
31 PJ_BEGIN_DECL
32
33
34 /**
35 * @file unicode.h
36 * @brief Provides Unicode conversion for Unicode OSes
37 */
38
39 /**
40 * Convert ANSI strings to Unicode strings.
41 *
42 * @param str The ANSI string to be converted.
43 * @param len The length of the input string.
44 * @param wbuf Buffer to hold the Unicode string output.
45 * @param wbuf_count Buffer size, in number of elements (not bytes).
46 *
47 * @return The Unicode string, NULL terminated.
48 */
49 PJ_DECL(wchar_t*) pj_ansi_to_unicode(const char *str, int len,
50 wchar_t *wbuf, int wbuf_count);
51
52
53 /**
54 * Convert Unicode string to ANSI string.
55 *
56 * @param wstr The Unicode string to be converted.
57 * @param len The length of the input string.
58 * @param buf Buffer to hold the ANSI string output.
59 * @param buf_size Size of the output buffer.
60 *
61 * @return The ANSI string, NULL terminated.
62 */
63 PJ_DECL(char*) pj_unicode_to_ansi(const wchar_t *wstr, pj_ssize_t len,
64 char *buf, int buf_size);
65
66
67 #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
68
69 /**
70 * This macro is used to declare temporary Unicode buffer for ANSI to
71 * Unicode conversion, and should be put in declaration section of a block.
72 * When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this
73 * macro will expand to nothing.
74 */
75 # define PJ_DECL_UNICODE_TEMP_BUF(buf,size) wchar_t buf[size];
76
77 /**
78 * This macro will convert ANSI string to native, when the platform's
79 * native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).
80 */
81 # define PJ_STRING_TO_NATIVE(s,buf,max) pj_ansi_to_unicode( \
82 s, strlen(s), \
83 buf, max)
84
85 /**
86 * This macro is used to declare temporary ANSI buffer for Unicode to
87 * ANSI conversion, and should be put in declaration section of a block.
88 * When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this
89 * macro will expand to nothing.
90 */
91 # define PJ_DECL_ANSI_TEMP_BUF(buf,size) char buf[size];
92
93
94 /**
95 * This macro will convert Unicode string to ANSI, when the platform's
96 * native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).
97 */
98 # define PJ_NATIVE_TO_STRING(cs,buf,max) pj_unicode_to_ansi( \
99 cs, wcslen(cs), \
100 buf, max)
101
102 #else
103
104 /**
105 * This macro is used to declare temporary Unicode buffer for ANSI to
106 * Unicode conversion, and should be put in declaration section of a block.
107 * When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this
108 * macro will expand to nothing.
109 */
110 # define PJ_DECL_UNICODE_TEMP_BUF(var,size)
111 /**
112 * This macro will convert ANSI string to native, when the platform's
113 * native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).
114 */
115 # define PJ_STRING_TO_NATIVE(s,buf,max) ((char*)s)
116 /**
117 * This macro is used to declare temporary ANSI buffer for Unicode to
118 * ANSI conversion, and should be put in declaration section of a block.
119 * When PJ_NATIVE_STRING_IS_UNICODE macro is not defined, this
120 * macro will expand to nothing.
121 */
122 # define PJ_DECL_ANSI_TEMP_BUF(buf,size)
123 /**
124 * This macro will convert Unicode string to ANSI, when the platform's
125 * native string is Unicode (PJ_NATIVE_STRING_IS_UNICODE is non-zero).
126 */
127 # define PJ_NATIVE_TO_STRING(cs,buf,max) ((char*)(const char*)cs)
128
129 #endif
130
131
132
133 PJ_END_DECL
134
135 /**
136 * @}
137 */
138
139
140 #endif /* __PJ_UNICODE_H__ */