comparison common/strhelp.h @ 251:c596568fa45b

Add utf16 conversion functions for Windows. This also includes a null pointer checking free.
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 01 Apr 2014 10:48:35 +0000
parents 6b4ad6ccc48e
children 4077eff1dd39
comparison
equal deleted inserted replaced
250:1e112cf41e92 251:c596568fa45b
4 #ifdef __cplusplus 4 #ifdef __cplusplus
5 extern "C" { 5 extern "C" {
6 #endif 6 #endif
7 7
8 #include <stdbool.h> 8 #include <stdbool.h>
9 #include <stddef.h>
9 10
10 /** 11 /**
11 * @file strhelp.h 12 * @file strhelp.h
12 * @brief Helper functions for c strings and memory management 13 * @brief Helper functions for c strings and memory management
13 * @details strhelp contains terminating memory allocation functions and 14 * @details strhelp contains terminating memory allocation functions and
17 18
18 void *xmalloc( size_t n ); 19 void *xmalloc( size_t n );
19 void *xrealloc( void *a, size_t n ); 20 void *xrealloc( void *a, size_t n );
20 void *xcalloc( size_t n, size_t m ); 21 void *xcalloc( size_t n, size_t m );
21 char *xstrndup( const char *string, const size_t len ); 22 char *xstrndup( const char *string, const size_t len );
23 void xfree ( void *p );
22 24
23 /** 25 /**
24 * @brief Returns the length of the given %NULL-terminated 26 * @brief Returns the length of the given %NULL-terminated
25 * string array str_array. 27 * string array str_array.
26 * @param[in] str_array a %NULL-terminated array of strings 28 * @param[in] str_array a %NULL-terminated array of strings
99 * 101 *
100 * @returns 0 on success a polarssl error or -1 otherwise 102 * @returns 0 on success a polarssl error or -1 otherwise
101 */ 103 */
102 int str_base64_decode(char **dst, size_t *dst_size, char *src, 104 int str_base64_decode(char **dst, size_t *dst_size, char *src,
103 size_t src_size); 105 size_t src_size);
106
107 #ifdef WIN32
108
109 /** @brief convert a utf8 string to utf16 wchar
110 *
111 * @param[in] string utf8 string. Must be at least len characters long.
112 * @param[in] len number of characters to be converted.
113 *
114 * @returns pointer to a newly allocated wchar array. NULL on error.
115 *
116 **/
117 wchar_t *utf8_to_wchar (const char *string, size_t len);
118
119 /** @brief convert a utf16 string to utf8
120 *
121 * @param[in] string utf16 string. Must be at least len characters long.
122 * @param[in] len number of characters to be converted.
123 *
124 * @returns pointer to a newly allocated char array. NULL on error.
125 *
126 **/
127 char *wchar_to_utf8 (const wchar_t *string, size_t len);
128 #endif
129
104 #ifdef __cplusplus 130 #ifdef __cplusplus
105 } 131 }
106 #endif 132 #endif
107 133
108 #endif 134 #endif

http://wald.intevation.org/projects/trustbridge/