/[public]/psiconv/trunk/lib/psiconv/unicode.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/unicode.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 217 Revision 231
142 142
143int psiconv_unicode_write_char(const psiconv_config config, 143int psiconv_unicode_write_char(const psiconv_config config,
144 psiconv_buffer buf, 144 psiconv_buffer buf,
145 int lev, psiconv_ucs2 value) 145 int lev, psiconv_ucs2 value)
146{ 146{
147 psiconv_u8 byte;
148 int i; 147 int i;
149 int res=0; 148 int res=0;
150 149
151 if (config->unicode) { 150 if (config->unicode) {
152 if (value < 0x80) { 151 if (value < 0x80) {
224 if (result) 223 if (result)
225 result[0] = 0; 224 result[0] = 0;
226 return result; 225 return result;
227} 226}
228 227
228
229psiconv_ucs2 *psiconv_unicode_from_list(psiconv_list input)
230{
231 psiconv_ucs2 *result;
232 int i;
233 psiconv_ucs2 *character;
234
235 if (!(result = malloc(sizeof(psiconv_ucs2) * (psiconv_list_length(input)+1))))
236 goto ERROR1;
237 for (i = 0; i < psiconv_list_length(input); i++) {
238 if (!(character = psiconv_list_get(input,i)))
239 goto ERROR2;
240 result[i] = *character;
241 }
242 result[i] = 0;
243 return result;
244
245ERROR2:
246 free(result);
247ERROR1:
248 return NULL;
249}
250
251
252psiconv_ucs2 *psiconv_unicode_strstr(const psiconv_ucs2 *haystack,
253 const psiconv_ucs2 *needle)
254{
255 int i,j,haystack_len,needle_len;
256 haystack_len = psiconv_unicode_strlen(haystack);
257 needle_len = psiconv_unicode_strlen(needle);
258
259
260
261 for (i = 0; i < haystack_len - needle_len + 1; i++) {
262 for (j = 0; j < needle_len; j++)
263 if (haystack[i+j] != needle[j])
264 break;
265 if (j == needle_len)
266 return (psiconv_ucs2 *) haystack+i;
267 }
268 return NULL;
269}

Legend:
Removed from v.217  
changed lines
  Added in v.231

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26