X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fmarcdisp.c;h=85acb07139e2470971e3ed442c22b58c9af8db45;hp=78244a0db551aa8e1e10e7fbae5adb6c5bac9cf1;hb=8ceaeefe2e491935cba91f56007308be6e4996e6;hpb=bbfac2e92dee794029b7a2ee6c843c9b99e22cc3 diff --git a/src/marcdisp.c b/src/marcdisp.c index 78244a0..85acb07 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ @@ -257,7 +257,7 @@ static int element_name_append_attribute_value( /* TODO Map special codes to something possible for XML ELEMENT names */ int encode = 0; - int index = 0; + size_t index = 0; int success = 0; for (index = 0; index < code_len; index++) { @@ -1266,19 +1266,21 @@ int yaz_marc_write_json(yaz_marc_t mt, WRBUF w) for (n = mt->nodes; n; n = n->next) { struct yaz_marc_subfield *s; - int i; const char *sep = ""; switch (n->which) { + case YAZ_MARC_LEADER: + case YAZ_MARC_COMMENT: + break; case YAZ_MARC_CONTROLFIELD: if (first) first = 0; else wrbuf_puts(w, ",\n"); wrbuf_puts(w, "\t\t{\n\t\t\t\""); - wrbuf_json_puts(w, n->u.controlfield.tag); + wrbuf_iconv_json_puts(w, mt->iconv_cd, n->u.controlfield.tag); wrbuf_puts(w, "\":\""); - wrbuf_json_puts(w, n->u.controlfield.data); + wrbuf_iconv_json_puts(w, mt->iconv_cd, n->u.controlfield.data); wrbuf_puts(w, "\"\n\t\t}"); break; case YAZ_MARC_DATAFIELD: @@ -1297,9 +1299,11 @@ int yaz_marc_write_json(yaz_marc_t mt, WRBUF w) wrbuf_puts(w, sep); sep = ",\n"; wrbuf_puts(w, "\t\t\t\t\t{\n\t\t\t\t\t\t\""); - wrbuf_json_write(w, s->code_data, using_code_len); + wrbuf_iconv_json_write(w, mt->iconv_cd, + s->code_data, using_code_len); wrbuf_puts(w, "\":\""); - wrbuf_json_puts(w, s->code_data + using_code_len); + wrbuf_iconv_json_puts(w, mt->iconv_cd, + s->code_data + using_code_len); wrbuf_puts(w, "\"\n\t\t\t\t\t}"); } wrbuf_puts(w, "\n\t\t\t\t]"); @@ -1308,8 +1312,7 @@ int yaz_marc_write_json(yaz_marc_t mt, WRBUF w) int i; for (i = 0; n->u.datafield.indicator[i]; i++) { - wrbuf_puts(w, ",\n"); - wrbuf_printf(w, "\t\t\t\t\"ind%d\":\"%c\"", i + 1, + wrbuf_printf(w, ",\n\t\t\t\t\"ind%d\":\"%c\"", i + 1, n->u.datafield.indicator[i]); } } @@ -1320,6 +1323,7 @@ int yaz_marc_write_json(yaz_marc_t mt, WRBUF w) } wrbuf_puts(w, "\n\t]\n"); wrbuf_puts(w, "}\n"); + return 0; } int yaz_marc_decode_wrbuf(yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) @@ -1461,6 +1465,16 @@ void yaz_marc_write_using_libxml2(yaz_marc_t mt, int enable) mt->write_using_libxml2 = enable; } +int yaz_marc_check_marc21_coding(const char *charset, + const char *marc_buf, int sz) +{ + if ((!yaz_matchstr(charset, "MARC8?") || + !yaz_matchstr(charset, "MARC8")) && marc_buf && sz > 25 + && marc_buf[9] == 'a') + return 1; + return 0; +} + /* * Local variables: * c-basic-offset: 4