X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ficonv_encode_danmarc.c;h=200e2f509add8eef41addfbc58789c3ab9bb0e67;hp=1afcf7c2f1e12183fd315e0c289611c74cbdd1f6;hb=HEAD;hpb=e462d48003aafc70536f9982b44edef5d32a5f6a diff --git a/src/iconv_encode_danmarc.c b/src/iconv_encode_danmarc.c index 1afcf7c..200e2f5 100644 --- a/src/iconv_encode_danmarc.c +++ b/src/iconv_encode_danmarc.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. */ /** @@ -25,16 +25,16 @@ static size_t write_danmarc(yaz_iconv_t cd, yaz_iconv_encoder_t en, { unsigned char *outp = (unsigned char *) *outbuf; - if (x == '@') + if (x == '@' || x == '*') { if (*outbytesleft < 2) { yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); return (size_t)(-1); } - *outp++ = x; + *outp++ = '@'; (*outbytesleft)--; - *outp++ = x; + *outp++ = (unsigned char) x; (*outbytesleft)--; } else if (x <= 255) @@ -44,19 +44,35 @@ static size_t write_danmarc(yaz_iconv_t cd, yaz_iconv_encoder_t en, yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); return (size_t)(-1); } - *outp++ = x; + *outp++ = (unsigned char) x; (*outbytesleft)--; } else - { /* full unicode, emit @XXXX */ + { if (*outbytesleft < 6) { yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); return (size_t)(-1); } - sprintf(*outbuf, "@%04lX", x); - outp += 5; - (*outbytesleft) -= 5; + switch (x) + { + case 0xa733: + *outp++ = '@'; + *outp++ = 0xe5; + (*outbytesleft) -= 2; + break; + case 0xa732: + *outp++ = '@'; + *outp++ = 0xc5; + (*outbytesleft) -= 2; + break; + default: + /* full unicode, emit @XXXX */ + sprintf(*outbuf, "@%04lX", x); + outp += 5; + (*outbytesleft) -= 5; + break; + } } *outbuf = (char *) outp; return 0;