2 * Copyright (C) 1995-2008, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: siconv.c,v 1.50 2008-03-12 08:53:28 adam Exp $
9 * \brief ISO-5428 character mapping (iconv)
23 unsigned long yaz_read_UCS4(yaz_iconv_t cd, unsigned char *inp,
24 size_t inbytesleft, size_t *no_read)
30 yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
35 x = (inp[0]<<24) | (inp[1]<<16) | (inp[2]<<8) | inp[3];
41 unsigned long yaz_read_UCS4LE(yaz_iconv_t cd, unsigned char *inp,
42 size_t inbytesleft, size_t *no_read)
48 yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
53 x = (inp[3]<<24) | (inp[2]<<16) | (inp[1]<<8) | inp[0];
59 size_t yaz_write_UCS4(yaz_iconv_t cd, unsigned long x,
60 char **outbuf, size_t *outbytesleft)
62 unsigned char *outp = (unsigned char *) *outbuf;
63 if (*outbytesleft >= 4)
65 *outp++ = (unsigned char) (x>>24);
66 *outp++ = (unsigned char) (x>>16);
67 *outp++ = (unsigned char) (x>>8);
68 *outp++ = (unsigned char) x;
73 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
76 *outbuf = (char *) outp;
80 size_t yaz_write_UCS4LE(yaz_iconv_t cd, unsigned long x,
81 char **outbuf, size_t *outbytesleft)
83 unsigned char *outp = (unsigned char *) *outbuf;
84 if (*outbytesleft >= 4)
86 *outp++ = (unsigned char) x;
87 *outp++ = (unsigned char) (x>>8);
88 *outp++ = (unsigned char) (x>>16);
89 *outp++ = (unsigned char) (x>>24);
94 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
97 *outbuf = (char *) outp;
106 * indent-tabs-mode: nil
108 * vim: shiftwidth=4 tabstop=8 expandtab