YAZ 5.35.1
yaz-iconv.h
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data.
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Index Data nor the names of its contributors
13 * may be used to endorse or promote products derived from this
14 * software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
33#ifndef YAZ_ICONV_H
34#define YAZ_ICONV_H
35
36#include <stddef.h>
37#include <yaz/yconfig.h>
38
40
43
45#define YAZ_ICONV_UNKNOWN 1
47#define YAZ_ICONV_E2BIG 2
49#define YAZ_ICONV_EILSEQ 3
51#define YAZ_ICONV_EINVAL 4
52
54YAZ_EXPORT yaz_iconv_t yaz_iconv_open(const char *tocode, const char *fromcode);
56YAZ_EXPORT size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft,
57 char **outbuf, size_t *outbytesleft);
59YAZ_EXPORT int yaz_iconv_error(yaz_iconv_t cd);
60
62YAZ_EXPORT int yaz_iconv_close(yaz_iconv_t cd);
63
65YAZ_EXPORT int yaz_iconv_isbuiltin(yaz_iconv_t cd);
66
67YAZ_EXPORT unsigned long yaz_read_UTF8_char(const unsigned char *inp,
68 size_t inbytesleft,
69 size_t *no_read,
70 int *error);
71
80YAZ_EXPORT size_t yaz_write_UTF8_char(unsigned long x,
81 char **outbuf, size_t *outbytesleft,
82 int *error);
83
84/* ctype.h macros ASCII based. That do not depend on LANG, nor require
85 unsigned int as argument */
86#define yaz_isdigit(x) ((x) >= '0' && (x) <= '9')
87#define yaz_isspace(x) strchr(" \f\r\n\t\v", x)
88#define yaz_toupper(x) ((x) + ('A' - 'a'))
89#define yaz_isupper(x) ((x) >= 'A' && (x) <= 'Z')
90#define yaz_tolower(x) ((x) + ('a' - 'A'))
91#define yaz_islower(x) ((x) >= 'a' && (x) <= 'z')
92
98YAZ_EXPORT int yaz_utf8_check(const char *cstr);
99
101
102#endif
103/*
104 * Local variables:
105 * c-basic-offset: 4
106 * c-file-style: "Stroustrup"
107 * indent-tabs-mode: nil
108 * End:
109 * vim: shiftwidth=4 tabstop=8 expandtab
110 */
111
size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
just like iconv(3)
Definition siconv.c:146
int yaz_iconv_close(yaz_iconv_t cd)
just like iconv_close(3)
Definition siconv.c:284
int yaz_iconv_isbuiltin(yaz_iconv_t cd)
tests whether conversion is handled by YAZ' iconv or system iconv
Definition siconv.c:45
int yaz_iconv_error(yaz_iconv_t cd)
returns last error - like errno for iconv(3)
Definition siconv.c:279
yaz_iconv_t yaz_iconv_open(const char *tocode, const char *fromcode)
just like iconv_open(3)
Definition siconv.c:95
int yaz_utf8_check(const char *cstr)
check whether string apppers to be UTF-8 encoded
Definition utf8.c:243
size_t yaz_write_UTF8_char(unsigned long x, char **outbuf, size_t *outbytesleft, int *error)
encodes UTF-8 sequence
Definition utf8.c:159
struct yaz_iconv_struct * yaz_iconv_t
yaz_iconv handle (similar to iconv_t)
Definition yaz-iconv.h:42
unsigned long yaz_read_UTF8_char(const unsigned char *inp, size_t inbytesleft, size_t *no_read, int *error)
Definition utf8.c:41
Header with fundamental macros.
#define YAZ_BEGIN_CDECL
Definition yconfig.h:56
#define YAZ_END_CDECL
Definition yconfig.h:57