3 #use MARC::File::XML(BinaryEncoding=>"utf8");
4 #use MARC::File::USMARC;
6 use C4::AuthoritiesMarc;
8 #MARC::File::XML::default_record_format("UNIMARCAUTH");
9 my $dbh = C4::Context->dbh;
10 my $rq= $dbh->prepare(qq|
11 SELECT authid,authtypecode
14 my $filename= shift @ARGV;
16 #ATTENTION : Mettre la base en utf8 auparavant.
17 #BEWARE : Set database into utf8 before.
18 #open FILEOUTPUT,">:utf8", "$filename" or die "unable to open $filename";
19 while (my ($authid,$authtypecode)=$rq->fetchrow){
20 my $record=AUTHgetauthority($dbh,$authid);
21 if (! utf8::is_utf8($record)) {
22 utf8::decode($record);
25 if (C4::Context->preference('marcflavour') eq "UNIMARC"){
26 $record->leader(' nac 22 1u 4500');
27 my $string=$1 if $time=~m/([0-9\-]+)/;
29 $string = sprintf("%-*s",26, $string);
30 substr($string,9,6,"frey50");
31 unless ($record->subfield('100',"a")){
32 $record->insert_fields_ordered(MARC::Field->new('100',"","","a"=>$string));
34 if ($record->field('152')){
35 if ($record->subfield('152','b')){
37 $record->field('152')->add_subfields("b"=>$authtypecode);
40 $record->insert_fields_ordered(MARC::Field->new('152',"","","b"=>$authtypecode));
42 unless ($record->field('001')){
43 $record->insert_fields_ordered(MARC::Field->new('001',$authid));
46 AUTHmodauthority($dbh,$authid,$record,1);
48 $record->encoding( 'UTF-8' );
50 # warn $record->as_usmarc;
51 # warn $record->as_formatted;
52 # warn $record->as_usmarc;
54 print $record->as_usmarc();