YAZ comes with yaz-marcdump:
This one liner from the man page will do the conversion you want:

yaz-marcdump -f MARC-8 -t UTF-8 -o marc -l 9=97 marc21.raw >marc21.utf8.raw

The -v option writes more information on parsing for those ill-formed records.

yaz-marcdump is fast. If you're only doing character encoding
conversion and not making other changes to the records, give
yaz-marcdump a try.

--Jason Ronallo

On 7/20/07, Tod Olson <[log in to unmask]> wrote:
> code4lib,
> Would any of you have a script for converting MARC records from MARC
> ANSEL to UTF-8 that you would be willing to share?
> I have millions of MARC records that I need to convert on a regular
> basis. Our data is too dirty for marc4j, and it's failure mode too
> severe. I understand that MARC::Record and MARC::Charset are more
> forgiving, but my Perl is minimal.
> Advice, sample code, pointers and the like are welcome.
> Tod Olson <[log in to unmask]>
> Systems Librarian
> University of Chicago Library