1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2013 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;
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);
51 { /* full unicode, emit @XXXX */
52 if (*outbytesleft < 6)
54 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
57 sprintf(*outbuf, "@%04lX", x);
61 *outbuf = (char *) outp;
65 yaz_iconv_encoder_t yaz_danmarc_encoder(const char *tocode,
66 yaz_iconv_encoder_t e)
69 if (!yaz_matchstr(tocode, "danmarc"))
71 e->write_handle = write_danmarc;
81 * c-file-style: "Stroustrup"
82 * indent-tabs-mode: nil
84 * vim: shiftwidth=4 tabstop=8 expandtab