YAZ  5.34.0
Macros | Typedefs | Functions
yaz-iconv.h File Reference

Header for YAZ iconv interface. More...

#include <stddef.h>
#include <yaz/yconfig.h>

Go to the source code of this file.

Macros

#define YAZ_ICONV_UNKNOWN   1
 error code: unknown More...
 
#define YAZ_ICONV_E2BIG   2
 error code: Not sufficient room for output buffer More...
 
#define YAZ_ICONV_EILSEQ   3
 error code: Invalid sequence More...
 
#define YAZ_ICONV_EINVAL   4
 error code: An incomplete multibyte sequence is in input buffer More...
 
#define yaz_isdigit(x)   ((x) >= '0' && (x) <= '9')
 
#define yaz_isspace(x)   strchr(" \f\r\n\t\v", x)
 
#define yaz_toupper(x)   ((x) + ('A' - 'a'))
 
#define yaz_isupper(x)   ((x) >= 'A' && (x) <= 'Z')
 
#define yaz_tolower(x)   ((x) + ('a' - 'A'))
 
#define yaz_islower(x)   ((x) >= 'a' && (x) <= 'z')
 

Typedefs

typedef struct yaz_iconv_structyaz_iconv_t
 yaz_iconv handle (similar to iconv_t) More...
 

Functions

yaz_iconv_t yaz_iconv_open (const char *tocode, const char *fromcode)
 just like iconv_open(3) More...
 
size_t yaz_iconv (yaz_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 just like iconv(3) More...
 
int yaz_iconv_error (yaz_iconv_t cd)
 returns last error - like errno for iconv(3) More...
 
int yaz_iconv_close (yaz_iconv_t cd)
 just like iconv_close(3) More...
 
int yaz_iconv_isbuiltin (yaz_iconv_t cd)
 tests whether conversion is handled by YAZ' iconv or system iconv More...
 
unsigned long yaz_read_UTF8_char (const unsigned char *inp, size_t inbytesleft, size_t *no_read, int *error)
 
size_t yaz_write_UTF8_char (unsigned long x, char **outbuf, size_t *outbytesleft, int *error)
 encodes UTF-8 sequence More...
 
int yaz_utf8_check (const char *cstr)
 check whether string apppers to be UTF-8 encoded More...
 

Detailed Description

Header for YAZ iconv interface.

Definition in file yaz-iconv.h.

Macro Definition Documentation

◆ YAZ_ICONV_E2BIG

#define YAZ_ICONV_E2BIG   2

error code: Not sufficient room for output buffer

Definition at line 47 of file yaz-iconv.h.

◆ YAZ_ICONV_EILSEQ

#define YAZ_ICONV_EILSEQ   3

error code: Invalid sequence

Definition at line 49 of file yaz-iconv.h.

◆ YAZ_ICONV_EINVAL

#define YAZ_ICONV_EINVAL   4

error code: An incomplete multibyte sequence is in input buffer

Definition at line 51 of file yaz-iconv.h.

◆ YAZ_ICONV_UNKNOWN

#define YAZ_ICONV_UNKNOWN   1

error code: unknown

Definition at line 45 of file yaz-iconv.h.

◆ yaz_isdigit

#define yaz_isdigit (   x)    ((x) >= '0' && (x) <= '9')

Definition at line 86 of file yaz-iconv.h.

◆ yaz_islower

#define yaz_islower (   x)    ((x) >= 'a' && (x) <= 'z')

Definition at line 91 of file yaz-iconv.h.

◆ yaz_isspace

#define yaz_isspace (   x)    strchr(" \f\r\n\t\v", x)

Definition at line 87 of file yaz-iconv.h.

◆ yaz_isupper

#define yaz_isupper (   x)    ((x) >= 'A' && (x) <= 'Z')

Definition at line 89 of file yaz-iconv.h.

◆ yaz_tolower

#define yaz_tolower (   x)    ((x) + ('a' - 'A'))

Definition at line 90 of file yaz-iconv.h.

◆ yaz_toupper

#define yaz_toupper (   x)    ((x) + ('A' - 'a'))

Definition at line 88 of file yaz-iconv.h.

Typedef Documentation

◆ yaz_iconv_t

typedef struct yaz_iconv_struct* yaz_iconv_t

yaz_iconv handle (similar to iconv_t)

Definition at line 42 of file yaz-iconv.h.

Function Documentation

◆ yaz_iconv()

size_t yaz_iconv ( yaz_iconv_t  cd,
char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft 
)

◆ yaz_iconv_close()

int yaz_iconv_close ( yaz_iconv_t  cd)

◆ yaz_iconv_error()

int yaz_iconv_error ( yaz_iconv_t  cd)

returns last error - like errno for iconv(3)

Definition at line 279 of file siconv.c.

References yaz_iconv_struct::my_errno.

Referenced by wrbuf_iconv_write2(), and yaz_write_marc8_generic().

◆ yaz_iconv_isbuiltin()

int yaz_iconv_isbuiltin ( yaz_iconv_t  cd)

tests whether conversion is handled by YAZ' iconv or system iconv

Definition at line 45 of file siconv.c.

References yaz_iconv_struct::decoder, yaz_iconv_struct::encoder, yaz_iconv_decoder_s::read_handle, and yaz_iconv_encoder_s::write_handle.

◆ yaz_iconv_open()

yaz_iconv_t yaz_iconv_open ( const char *  tocode,
const char *  fromcode 
)

◆ yaz_read_UTF8_char()

unsigned long yaz_read_UTF8_char ( const unsigned char *  inp,
size_t  inbytesleft,
size_t *  no_read,
int *  error 
)

Definition at line 41 of file utf8.c.

References YAZ_ICONV_EILSEQ, and YAZ_ICONV_EINVAL.

Referenced by cdata_one_character(), read_utf8(), and yaz_utf8_check().

◆ yaz_utf8_check()

int yaz_utf8_check ( const char *  cstr)

check whether string apppers to be UTF-8 encoded

Parameters
cstrstring to check
Return values
1OK (appears to be UTF-8)
0definitely not UTF-8

Definition at line 243 of file utf8.c.

References yaz_read_UTF8_char().

◆ yaz_write_UTF8_char()

size_t yaz_write_UTF8_char ( unsigned long  x,
char **  outbuf,
size_t *  outbytesleft,
int *  error 
)

encodes UTF-8 sequence

Parameters
xthe UNICODE value
outbufoutput buffer pointer, updated if conversion is successful
outbytesleftlength of buffer, updated if conversino is successful
errorpointer to error code if error occurs
Return values
0if successful
-1for error

Definition at line 159 of file utf8.c.

References YAZ_ICONV_E2BIG.

Referenced by json_one_char(), lookup_marc8(), and write_UTF8().