* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: yaz-iconv.h,v 1.10 2006-08-04 14:35:39 adam Exp $
+ * $Id: yaz-iconv.h,v 1.11 2006-08-24 10:01:03 adam Exp $
*/
/**
* \file yaz-iconv.h
YAZ_EXPORT int yaz_strcmp_del(const char *a, const char *b, const char *b_del);
+/** \brief decodes UTF-8 sequence
+ \param inp input buffer with UTF-8 bytes
+ \param inbytesleft length of input buffer
+ \param no_read holds number of bytes read if conversion is successful
+ \param error pointer to error code if error occurs
+ \retval 0 if error
+ \retval >0 if conversion is successful
+*/
YAZ_EXPORT unsigned long yaz_read_UTF8_char(unsigned char *inp,
size_t inbytesleft,
size_t *no_read,
int *error);
+/** \brief encodes UTF-8 sequence
+ \param x the UNICODE value
+ \param outbuf output buffer pointer, updated if conversion is successful
+ \param outbytesleft length of buffer, updated if conversino is successful
+ \param error pointer to error code if error occurs
+ \retval 0 if successful
+ \retval -1 for error
+*/
+YAZ_EXPORT size_t yaz_write_UTF8_char(unsigned long x,
+ char **outbuf, size_t *outbytesleft,
+ int *error);
+
YAZ_END_CDECL
#endif
* Copyright (C) 1995-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: siconv.c,v 1.24 2006-08-04 14:35:40 adam Exp $
+ * $Id: siconv.c,v 1.25 2006-08-24 10:01:03 adam Exp $
*/
/**
* \file siconv.c
}
}
-static size_t yaz_write_UTF8 (yaz_iconv_t cd, unsigned long x,
- char **outbuf, size_t *outbytesleft,
- int last)
+static size_t yaz_write_UTF8(yaz_iconv_t cd, unsigned long x,
+ char **outbuf, size_t *outbytesleft,
+ int last)
+{
+ return yaz_write_UTF8_char(x, outbuf, outbytesleft, &cd->my_errno);
+}
+
+size_t yaz_write_UTF8_char(unsigned long x,
+ char **outbuf, size_t *outbytesleft,
+ int *error)
{
unsigned char *outp = (unsigned char *) *outbuf;
}
else
{
- cd->my_errno = YAZ_ICONV_E2BIG; /* not room for output */
+ *error = YAZ_ICONV_E2BIG; /* not room for output */
return (size_t)(-1);
}
*outbuf = (char *) outp;