1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2009 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <yaz/diagbib1.h>
28 /* convert APT search term to UTF8 */
29 ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
33 Z_Term *term = zapt->term;
38 if (zh->iconv_to_utf8 != 0)
40 char *inbuf = (char *) term->u.general->buf;
41 size_t inleft = term->u.general->len;
43 size_t outleft = IT_MAX_WORD-1;
46 ret = yaz_iconv(zh->iconv_to_utf8, &inbuf, &inleft,
48 if (ret == (size_t)(-1))
50 ret = yaz_iconv(zh->iconv_to_utf8, 0, 0, 0, 0);
53 YAZ_BIB1_QUERY_TERM_INCLUDES_CHARS_THAT_DO_NOT_TRANSLATE_INTO_,
57 yaz_iconv(zh->iconv_to_utf8, 0, 0, &outbuf, &outleft);
62 sizez = term->u.general->len;
63 if (sizez > IT_MAX_WORD-1)
64 sizez = IT_MAX_WORD-1;
65 memcpy (termz, term->u.general->buf, sizez);
69 case Z_Term_characterString:
70 sizez = strlen(term->u.characterString);
71 if (sizez > IT_MAX_WORD-1)
72 sizez = IT_MAX_WORD-1;
73 memcpy (termz, term->u.characterString, sizez);
77 zebra_setError(zh, YAZ_BIB1_UNSUPP_CODED_VALUE_FOR_TERM, 0);
85 * c-file-style: "Stroustrup"
86 * indent-tabs-mode: nil
88 * vim: shiftwidth=4 tabstop=8 expandtab