- unsigned char c, str[1024], begin, end, *p;
-
+ char str[1024];
+
+ ucs4_t arg[512];
+ ucs4_t arg_prim[512];
+ ucs4_t *s0, *s = arg;
+ ucs4_t c, begin, end;
+ size_t i;
+
+ if (t_unicode != 0)
+ {
+ char *outbuf = (char *) arg;
+ char *inbuf = s_native;
+ size_t outbytesleft = sizeof(arg)-4;
+ size_t inbytesleft = strlen(s_native);
+ size_t ret;
+ ret = yaz_iconv(t_unicode, &inbuf, &inbytesleft,
+ &outbuf, &outbytesleft);
+ if (ret != (size_t)(-1))
+ ret = yaz_iconv(t_unicode, 0, 0, &outbuf, &outbytesleft);
+
+ if (ret == (size_t)(-1))
+ return -1;
+ i = (outbuf - (char*) arg)/sizeof(ucs4_t);
+ }
+ else
+ {
+ for (i = 0; s_native[i]; i++)
+ arg[i] = s_native[i] & 255; /* ISO-8859-1 conversion */
+ }
+ arg[i] = 0; /* terminate */
+ if (s[0] == 0xfeff || s[0] == 0xfeff) /* skip byte Order Mark */
+ s++;