… | |
… | |
224 | if (result) |
224 | if (result) |
225 | result[0] = 0; |
225 | result[0] = 0; |
226 | return result; |
226 | return result; |
227 | } |
227 | } |
228 | |
228 | |
|
|
229 | |
|
|
230 | psiconv_ucs2 *psiconv_unicode_from_list(psiconv_list input) |
|
|
231 | { |
|
|
232 | psiconv_ucs2 *result; |
|
|
233 | int i; |
|
|
234 | psiconv_ucs2 *character; |
|
|
235 | |
|
|
236 | if (!(result = malloc(sizeof(psiconv_ucs2) * (psiconv_list_length(input)+1)))) |
|
|
237 | goto ERROR1; |
|
|
238 | for (i = 0; i < psiconv_list_length(input); i++) { |
|
|
239 | if (!(character = psiconv_list_get(input,i))) |
|
|
240 | goto ERROR2; |
|
|
241 | result[i] = *character; |
|
|
242 | } |
|
|
243 | result[i] = 0; |
|
|
244 | return result; |
|
|
245 | |
|
|
246 | ERROR2: |
|
|
247 | free(result); |
|
|
248 | ERROR1: |
|
|
249 | return NULL; |
|
|
250 | } |
|
|
251 | |
|
|
252 | |
|
|
253 | psiconv_ucs2 *psiconv_unicode_strstr(const psiconv_ucs2 *haystack, |
|
|
254 | const psiconv_ucs2 *needle) |
|
|
255 | { |
|
|
256 | int i,j,haystack_len,needle_len; |
|
|
257 | haystack_len = psiconv_unicode_strlen(haystack); |
|
|
258 | needle_len = psiconv_unicode_strlen(needle); |
|
|
259 | |
|
|
260 | |
|
|
261 | |
|
|
262 | for (i = 0; i < haystack_len - needle_len + 1; i++) { |
|
|
263 | for (j = 0; j < needle_len; j++) |
|
|
264 | if (haystack[i+j] != needle[j]) |
|
|
265 | break; |
|
|
266 | if (j == needle_len) |
|
|
267 | return haystack+i; |
|
|
268 | } |
|
|
269 | return NULL; |
|
|
270 | } |