X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fmarcdump.c;h=940ed4d51a63d9a8eb6bd84f13d8a07d8ca1cbce;hb=refs%2Ftags%2Fv5.6.0;hp=cec66ab347d4320f050eaa2499c31524bfb3ad69;hpb=725b07a551ac42b73d3b621e6a9b696cd13f42d0;p=yaz-moved-to-github.git diff --git a/util/marcdump.c b/util/marcdump.c index cec66ab..940ed4d 100644 --- a/util/marcdump.c +++ b/util/marcdump.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ @@ -319,6 +319,7 @@ static void dump(const char *fname, const char *from, const char *to, size_t len_result; size_t r; char buf[100001]; + yaz_iconv_t cd1 = 0; r = fread(buf, 1, 5, inf); if (r < 5) @@ -428,7 +429,21 @@ static void dump(const char *fname, const char *from, const char *to, } } len_result = rlen; + + if (yaz_marc_check_marc21_coding(from, buf, 26)) + { + cd1 = yaz_iconv_open(to, "utf-8"); + if (cd1) + yaz_marc_iconv(mt, cd1); + } r = yaz_marc_decode_buf(mt, buf, -1, &result, &len_result); + + if (cd1) + { + yaz_iconv_close(cd1); + yaz_marc_iconv(mt, cd); + } + if (r == -1) no_errors++; if (r > 0 && result && len_result)