--- psiconv/trunk/lib/psiconv/unicode.c 2004/02/23 17:57:57 227 +++ psiconv/trunk/lib/psiconv/unicode.c 2004/02/25 16:11:17 228 @@ -226,3 +226,45 @@ return result; } + +psiconv_ucs2 *psiconv_unicode_from_list(psiconv_list input) +{ + psiconv_ucs2 *result; + int i; + psiconv_ucs2 *character; + + if (!(result = malloc(sizeof(psiconv_ucs2) * (psiconv_list_length(input)+1)))) + goto ERROR1; + for (i = 0; i < psiconv_list_length(input); i++) { + if (!(character = psiconv_list_get(input,i))) + goto ERROR2; + result[i] = *character; + } + result[i] = 0; + return result; + +ERROR2: + free(result); +ERROR1: + return NULL; +} + + +psiconv_ucs2 *psiconv_unicode_strstr(const psiconv_ucs2 *haystack, + const psiconv_ucs2 *needle) +{ + int i,j,haystack_len,needle_len; + haystack_len = psiconv_unicode_strlen(haystack); + needle_len = psiconv_unicode_strlen(needle); + + + + for (i = 0; i < haystack_len - needle_len + 1; i++) { + for (j = 0; j < needle_len; j++) + if (haystack[i+j] != needle[j]) + break; + if (j == needle_len) + return haystack+i; + } + return NULL; +}