1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2009 Index Data
3 * See the file LICENSE for details.
7 * \brief WCHAR_T iconv encoding / decoding
22 #include <yaz/xmalloc.h>
27 unsigned long compose_char;
31 static size_t write_wchar_t(yaz_iconv_t cd, yaz_iconv_encoder_t en,
33 char **outbuf, size_t *outbytesleft)
35 unsigned char *outp = (unsigned char *) *outbuf;
37 if (*outbytesleft >= sizeof(wchar_t))
40 memcpy(outp, &wch, sizeof(wch));
42 (*outbytesleft) -= sizeof(wch);
46 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
49 *outbuf = (char *) outp;
54 yaz_iconv_encoder_t yaz_wchar_encoder(const char *tocode,
55 yaz_iconv_encoder_t e)
59 if (!yaz_matchstr(tocode, "wchar_t"))
61 e->write_handle = write_wchar_t;
69 static unsigned long read_wchar_t(yaz_iconv_t cd, yaz_iconv_decoder_t d,
71 size_t inbytesleft, size_t *no_read)
75 if (inbytesleft < sizeof(wchar_t))
77 yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
83 memcpy(&wch, inp, sizeof(wch));
85 *no_read = sizeof(wch);
91 yaz_iconv_decoder_t yaz_wchar_decoder(const char *fromcode,
92 yaz_iconv_decoder_t d)
96 if (!yaz_matchstr(fromcode, "wchar_t"))
98 d->read_handle = read_wchar_t;
109 * c-file-style: "Stroustrup"
110 * indent-tabs-mode: nil
112 * vim: shiftwidth=4 tabstop=8 expandtab