1 /* This file is part of the Zebra server.
2 Copyright (C) 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
27 #include <yaz/diagbib1.h>
31 /* convert APT search term to UTF8 */
32 ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
36 Z_Term *term = zapt->term;
41 if (zh->iconv_to_utf8 != 0)
43 char *inbuf = (char *) term->u.general->buf;
44 size_t inleft = term->u.general->len;
46 size_t outleft = IT_MAX_WORD-1;
49 ret = yaz_iconv(zh->iconv_to_utf8, &inbuf, &inleft,
51 if (ret == (size_t)(-1))
53 int iconv_error = yaz_iconv_error(zh->iconv_to_utf8);
55 ret = yaz_iconv(zh->iconv_to_utf8, 0, 0, 0, 0);
58 iconv_error == YAZ_ICONV_E2BIG ?
59 YAZ_BIB1_TOO_MANY_CHARS_IN_SEARCH_STATEMENT :
60 YAZ_BIB1_QUERY_TERM_INCLUDES_CHARS_THAT_DO_NOT_TRANSLATE_INTO_,
64 yaz_iconv(zh->iconv_to_utf8, 0, 0, &outbuf, &outleft);
69 sizez = term->u.general->len;
70 if (sizez > IT_MAX_WORD-1)
71 sizez = IT_MAX_WORD-1;
72 memcpy (termz, term->u.general->buf, sizez);
76 case Z_Term_characterString:
77 sizez = strlen(term->u.characterString);
78 if (sizez > IT_MAX_WORD-1)
79 sizez = IT_MAX_WORD-1;
80 memcpy (termz, term->u.characterString, sizez);
84 zebra_setError(zh, YAZ_BIB1_UNSUPP_CODED_VALUE_FOR_TERM, 0);
92 * c-file-style: "Stroustrup"
93 * indent-tabs-mode: nil
95 * vim: shiftwidth=4 tabstop=8 expandtab