From df4e32bd1592e083911e2283b399d0f935886609 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 21 Jan 2025 09:16:02 +0100 Subject: [PATCH] Bug 17791: Fix Z39.50/XSLT import encoding issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test plan: 1. On UNIMARC system, create a Z39.50 server configuration: Name: LOC_NO_XSLT Hostname: lx2.loc.gov Port: 210 Database: LCDB Preselected: yes Syntax: MARC21/USMARC Encoding: utf8 Record Type: bibliographic 2. Duplicate this Z39.50 server configuration, change its name to "LOC_WITH_XSLT" and set "XSLT File(s) for transforming results" to the absolute path of a MARC21 to UNIMARC XSL file. You can download one from here: https://raw.githubusercontent.com/Gelow/unimarc/refs/heads/master/marc21xml2unimarc.xsl 3. Go to Cataloguing → New from Z39.50/SRU 4. Search both servers for a book entitled "comprendre un pays". That should give you only one result for each server 5. On results list, press «MARC» to see MARC fields. The record from LOC_NO_XSLT should have its 100$a replaced by something like "20250121 frey50" and the rest of the record should be a valid MARC21 record The record from LOC_WITH_XSLT should also have a 100$a looking like "20250121 frey50" but it might be different depending on the XSLT used (the important part is the "50" at positions 26-27) It should also have a 700 field that look like this: $a Simon $b Jean-François but again, it depends on the XSLT used. The 700$a should NOT contain "20250121 frey50" --- C4/Breeding.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index 86c5cbb588..c630124311 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -294,11 +294,13 @@ sub _handle_one_result { $servhref->{syntax} ); $marcrecord->encoding('UTF-8'); } else { - ($marcrecord) = MarcToUTF8Record($raw, C4::Context->preference('marcflavour'), $servhref->{encoding} // "iso-5426" ); #ignores charset return values + my $marcflavour = $servhref->{syntax} eq 'UNIMARC' ? 'UNIMARC' : 'MARC21'; + ($marcrecord) = MarcToUTF8Record($raw, $marcflavour, $servhref->{encoding} // "iso-5426" ); #ignores charset return values } SetUTF8Flag($marcrecord); my $error; ( $marcrecord, $error ) = _do_xslt_proc($marcrecord, $servhref, $xslh); + C4::Charset::SetMarcUnicodeFlag($marcrecord, C4::Context->preference('marcflavour')); my $batch_id = GetZ3950BatchId($servhref->{servername}); my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0); -- 2.39.2