- # retrieve biblios from shelf
- my $firstpass = 1;
- foreach my $biblio (@bibs) {
-
- my $record = GetMarcBiblio($biblio);
-
- switch ($format) {
- case "iso2709" { $output .= $record->as_usmarc(); }
- case "ris" { $output .= marc2ris($record); }
- case "bibtex" { $output .= marc2bibtex($record, $biblio); }
- # We're in the case of a csv profile (firstpass is used for headers printing) :
- case /^\d+$/ { $output .= marc2csv($biblio, $format, $firstpass); }
- }
- $firstpass = 0;
-
+ # CSV
+ if ($format =~ /^\d+$/) {
+
+ $output = marc2csv(\@bibs, $format);
+
+ # Other formats
+ } else {
+
+ foreach my $biblio (@bibs) {
+
+ my $record = GetMarcBiblio({
+ biblionumber => $biblio,
+ embed_items => 1 });
+ next unless $record;
+
+ if ($format eq 'iso2709') {
+ #NOTE: If we don't explicitly UTF-8 encode the output,
+ #the browser will guess the encoding, and it won't always choose UTF-8.
+ $output .= encode("UTF-8", $record->as_usmarc()) // q{};
+ }
+ elsif ($format eq 'ris') {
+ $output .= marc2ris($record);
+ }
+ elsif ($format eq 'bibtex') {
+ $output .= marc2bibtex($record, $biblio);
+ }
+ }