1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
12 #include <yaz/query-charset.h>
13 #include <yaz/copy_types.h>
14 #include <yaz/pquery.h>
15 #include <yaz/querytowrbuf.h>
18 enum query_charset_status {
26 enum query_charset_status t(yaz_iconv_t cd,
27 const char *pqf, const char *expect_pqf)
29 YAZ_PQF_Parser parser = yaz_pqf_create();
30 ODR odr = odr_createmem(ODR_ENCODE);
32 enum query_charset_status status = NO_ERROR;
38 rpn = yaz_pqf_parse(parser, odr, pqf);
40 yaz_pqf_destroy(parser);
46 WRBUF w = wrbuf_alloc();
47 Z_RPNQuery *r2 = yaz_copy_z_RPNQuery(rpn, odr);
51 yaz_query_charset_convert_rpnquery(rpn, odr, cd);
52 yaz_rpnquery_to_wrbuf(w, rpn);
53 if (!expect_pqf || strcmp(expect_pqf, wrbuf_cstr(w)) == 0)
58 printf("Result: %s\n", wrbuf_cstr(w));
68 yaz_iconv_t cd = yaz_iconv_open("iso-8859-1", "utf-8");
74 YAZ_CHECK_EQ(t(cd, "@attr 1=4 bad query", 0), PQF_FAILED);
75 YAZ_CHECK_EQ(t(cd, "@attr 1=4 ok", "@attrset Bib-1 @attr 1=4 ok"), MATCH);
77 /* m followed by latin smaller letter ae */
78 YAZ_CHECK_EQ(t(cd, "@attr 1=4 m\xc3\xa6", "@attrset Bib-1 @attr 1=4 m\xe6"), MATCH);
83 int main (int argc, char **argv)
85 YAZ_CHECK_INIT(argc, argv);
93 * c-file-style: "Stroustrup"
94 * indent-tabs-mode: nil
96 * vim: shiftwidth=4 tabstop=8 expandtab