1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2012 Index Data
3 * See the file LICENSE for details.
7 * \brief WCHAR_T iconv encoding / decoding
21 #include <yaz/xmalloc.h>
26 unsigned long compose_char;
30 static size_t write_wchar_t(yaz_iconv_t cd, yaz_iconv_encoder_t en,
32 char **outbuf, size_t *outbytesleft)
34 unsigned char *outp = (unsigned char *) *outbuf;
36 if (*outbytesleft >= sizeof(wchar_t))
39 memcpy(outp, &wch, sizeof(wch));
41 (*outbytesleft) -= sizeof(wch);
45 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
48 *outbuf = (char *) outp;
53 yaz_iconv_encoder_t yaz_wchar_encoder(const char *tocode,
54 yaz_iconv_encoder_t e)
58 if (!yaz_matchstr(tocode, "wchar_t"))
60 e->write_handle = write_wchar_t;
68 static unsigned long read_wchar_t(yaz_iconv_t cd, yaz_iconv_decoder_t d,
70 size_t inbytesleft, size_t *no_read)
74 if (inbytesleft < sizeof(wchar_t))
76 yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
82 memcpy(&wch, inp, sizeof(wch));
84 *no_read = sizeof(wch);
90 yaz_iconv_decoder_t yaz_wchar_decoder(const char *fromcode,
91 yaz_iconv_decoder_t d)
95 if (!yaz_matchstr(fromcode, "wchar_t"))
97 d->read_handle = read_wchar_t;
108 * c-file-style: "Stroustrup"
109 * indent-tabs-mode: nil
111 * vim: shiftwidth=4 tabstop=8 expandtab