1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2009 Index Data
3 * See the file LICENSE for details.
9 #include <yaz/query-charset.h>
10 #include <yaz/copy_types.h>
11 #include <yaz/pquery.h>
12 #include <yaz/querytowrbuf.h>
15 enum query_charset_status {
23 enum query_charset_status t(yaz_iconv_t cd,
24 const char *pqf, const char *expect_pqf)
26 YAZ_PQF_Parser parser = yaz_pqf_create();
27 ODR odr = odr_createmem(ODR_ENCODE);
29 enum query_charset_status status = NO_ERROR;
35 rpn = yaz_pqf_parse(parser, odr, pqf);
37 yaz_pqf_destroy(parser);
43 WRBUF w = wrbuf_alloc();
44 Z_RPNQuery *r2 = yaz_copy_z_RPNQuery(rpn, odr);
48 yaz_query_charset_convert_rpnquery(rpn, odr, cd);
49 yaz_rpnquery_to_wrbuf(w, rpn);
50 if (!expect_pqf || strcmp(expect_pqf, wrbuf_cstr(w)) == 0)
55 printf("Result: %s\n", wrbuf_cstr(w));
65 yaz_iconv_t cd = yaz_iconv_open("iso-8859-1", "utf-8");
71 YAZ_CHECK_EQ(t(cd, "@attr 1=4 bad query", 0), PQF_FAILED);
72 YAZ_CHECK_EQ(t(cd, "@attr 1=4 ok", "@attrset Bib-1 @attr 1=4 ok"), MATCH);
74 /* m followed by latin smaller letter ae */
75 YAZ_CHECK_EQ(t(cd, "@attr 1=4 m\xc3\xa6", "@attrset Bib-1 @attr 1=4 m\xe6"), MATCH);
80 int main (int argc, char **argv)
82 YAZ_CHECK_INIT(argc, argv);
90 * c-file-style: "Stroustrup"
91 * indent-tabs-mode: nil
93 * vim: shiftwidth=4 tabstop=8 expandtab