1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
7 * \brief Danmarc2 character set encoding
19 #include <yaz/xmalloc.h>
22 static size_t write_danmarc(yaz_iconv_t cd, yaz_iconv_encoder_t en,
24 char **outbuf, size_t *outbytesleft)
26 unsigned char *outp = (unsigned char *) *outbuf;
28 if (x == '@' || x == '*')
30 if (*outbytesleft < 2)
32 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
42 if (*outbytesleft < 1)
44 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
52 if (*outbytesleft < 6)
54 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
70 /* full unicode, emit @XXXX */
71 sprintf(*outbuf, "@%04lX", x);
77 *outbuf = (char *) outp;
81 yaz_iconv_encoder_t yaz_danmarc_encoder(const char *tocode,
82 yaz_iconv_encoder_t e)
85 if (!yaz_matchstr(tocode, "danmarc"))
87 e->write_handle = write_danmarc;
97 * c-file-style: "Stroustrup"
98 * indent-tabs-mode: nil
100 * vim: shiftwidth=4 tabstop=8 expandtab