+ yaz_log (YLOG_DEBUG, "set map %.*s", (int) strlen(s), s);
+ set_map_string(arg->map->input, arg->map->nmem, s, strlen(s), arg->string,
+ 0);
+ for (s = arg->string; *s; s++)
+ yaz_log (YLOG_DEBUG, " %3d", (unsigned char) *s);
+}
+
+/*
+ * Add a query map to the string contained in the argument.
+ */
+static void fun_add_qmap(const char *s, void *data, int num)
+{
+ chrwork *arg = (chrwork *) data;
+
+ assert(arg->map->q_input);
+ yaz_log (YLOG_DEBUG, "set qmap %.*s", (int) strlen(s), s);
+ set_map_string(arg->map->q_input, arg->map->nmem, s,
+ strlen(s), arg->string, 0);
+ for (s = arg->string; *s; s++)
+ yaz_log (YLOG_DEBUG, " %3d", (unsigned char) *s);
+}
+
+static int scan_to_utf8 (yaz_iconv_t t, ucs4_t *from, size_t inlen,
+ char *outbuf, size_t outbytesleft)
+{
+ size_t inbytesleft = inlen * sizeof(ucs4_t);
+ char *inbuf = (char*) from;
+ size_t ret;
+
+ if (t == 0)
+ *outbuf++ = *from; /* ISO-8859-1 is OK here */
+ else
+ {
+ ret = yaz_iconv (t, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+ if (ret == (size_t) (-1))
+ {
+ yaz_log(YLOG_LOG, "from: %2X %2X %2X %2X",
+ from[0], from[1], from[2], from[3]);
+ yaz_log (YLOG_WARN|YLOG_ERRNO, "bad unicode sequence");
+ return -1;
+ }
+ }
+ *outbuf = '\0';
+ return 0;