YAZ  5.23.1
Functions
utf8.c File Reference

UTF-8 encoding / decoding. More...

#include <assert.h>
#include <errno.h>
#include <string.h>
#include "iconv-p.h"

Go to the source code of this file.

Functions

static size_t init_utf8 (yaz_iconv_t cd, yaz_iconv_decoder_t d, unsigned char *inp, size_t inbytesleft, size_t *no_read)
 
unsigned long yaz_read_UTF8_char (const unsigned char *inp, size_t inbytesleft, size_t *no_read, int *error)
 
static unsigned long read_utf8 (yaz_iconv_t cd, yaz_iconv_decoder_t d, unsigned char *inp, size_t inbytesleft, size_t *no_read)
 
static size_t write_UTF8 (yaz_iconv_t cd, yaz_iconv_encoder_t en, unsigned long x, char **outbuf, size_t *outbytesleft)
 
size_t yaz_write_UTF8_char (unsigned long x, char **outbuf, size_t *outbytesleft, int *error)
 encodes UTF-8 sequence More...
 
yaz_iconv_encoder_t yaz_utf8_encoder (const char *tocode, yaz_iconv_encoder_t e)
 
yaz_iconv_decoder_t yaz_utf8_decoder (const char *fromcode, yaz_iconv_decoder_t d)
 
int yaz_utf8_check (const char *str)
 check whether string apppers to be UTF-8 encoded More...
 

Detailed Description

UTF-8 encoding / decoding.

Definition in file utf8.c.

Function Documentation

static size_t init_utf8 ( yaz_iconv_t  cd,
yaz_iconv_decoder_t  d,
unsigned char *  inp,
size_t  inbytesleft,
size_t *  no_read 
)
static

Definition at line 20 of file utf8.c.

References YAZ_ICONV_EINVAL, and yaz_iconv_set_errno().

Referenced by yaz_utf8_decoder().

static unsigned long read_utf8 ( yaz_iconv_t  cd,
yaz_iconv_decoder_t  d,
unsigned char *  inp,
size_t  inbytesleft,
size_t *  no_read 
)
static

Definition at line 138 of file utf8.c.

References yaz_iconv_set_errno(), and yaz_read_UTF8_char().

Referenced by yaz_utf8_decoder().

static size_t write_UTF8 ( yaz_iconv_t  cd,
yaz_iconv_encoder_t  en,
unsigned long  x,
char **  outbuf,
size_t *  outbytesleft 
)
static

Definition at line 149 of file utf8.c.

References yaz_iconv_set_errno(), and yaz_write_UTF8_char().

Referenced by yaz_utf8_encoder().

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().

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_iconv_decoder_t yaz_utf8_decoder ( const char *  fromcode,
yaz_iconv_decoder_t  d 
)
yaz_iconv_encoder_t yaz_utf8_encoder ( const char *  tocode,
yaz_iconv_encoder_t  e 
)

Definition at line 219 of file utf8.c.

References yaz_iconv_encoder_s::write_handle, write_UTF8(), and yaz_matchstr().

Referenced by prepare_encoders().

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().