X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ficonv_encode_danmarc.c;h=bc7d62af027d4961b44a5aca14568667b02abd30;hp=1afcf7c2f1e12183fd315e0c289611c74cbdd1f6;hb=3d6e2f0931ae87fe01e857d4573d946f6cd8e6f1;hpb=e462d48003aafc70536f9982b44edef5d32a5f6a diff --git a/src/iconv_encode_danmarc.c b/src/iconv_encode_danmarc.c index 1afcf7c..bc7d62a 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,14 +25,14 @@ 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; (*outbytesleft)--; @@ -48,15 +48,31 @@ static size_t write_danmarc(yaz_iconv_t cd, yaz_iconv_encoder_t en, (*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;