From b8129e460a97429d0ed0109bb0367fd83b2abfac Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 27 Jun 2011 13:44:19 +0200 Subject: [PATCH] zoom: assume marc-8 by default for records except XML. --- src/filter_zoom.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index d381d43..a611381 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -743,6 +743,7 @@ Z_Records *yf::Zoom::Frontend::get_records(Odr_int start, Z_Records *records = 0; bool enable_pz2_retrieval = false; // whether target profile is used bool enable_pz2_transform = false; // whether XSLT is used as well + bool assume_marc8_charset = false; if (start < 0 || number_to_present <= 0) return records; @@ -774,7 +775,11 @@ Z_Records *yf::Zoom::Frontend::get_records(Odr_int start, if (enable_pz2_retrieval) { if (b->sptr->request_syntax.length()) + { syntax_name = b->sptr->request_syntax.c_str(); + if (strcmp(syntax_name, "xml")) + assume_marc8_charset = true; + } } else if (preferredRecordSyntax) syntax_name = @@ -825,16 +830,18 @@ Z_Records *yf::Zoom::Frontend::get_records(Odr_int start, else if (enable_pz2_retrieval) { char rec_type_str[100]; + const char *record_encoding = 0; + + if (b->sptr->record_encoding.length()) + record_encoding = b->sptr->record_encoding.c_str(); + else if (assume_marc8_charset) + record_encoding = "marc8"; - strcpy(rec_type_str, b->sptr->use_turbomarc ? - "txml" : "xml"); - // prevent buffer overflow ... - if (b->sptr->record_encoding.length() > 0 && - b->sptr->record_encoding.length() < - (sizeof(rec_type_str)-20)) + strcpy(rec_type_str, b->sptr->use_turbomarc ? "txml" : "xml"); + if (record_encoding) { strcat(rec_type_str, "; charset="); - strcat(rec_type_str, b->sptr->record_encoding.c_str()); + strcat(rec_type_str, record_encoding); } int rec_len; -- 1.7.10.4