Libparserutils
codec.h
Go to the documentation of this file.
1 /*
2  * This file is part of LibParserUtils.
3  * Licensed under the MIT License,
4  * http://www.opensource.org/licenses/mit-license.php
5  * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
6  */
7 
8 #ifndef parserutils_charset_codec_h_
9 #define parserutils_charset_codec_h_
10 
11 #ifdef __cplusplus
12 extern "C"
13 {
14 #endif
15 
16 #include <inttypes.h>
17 
18 #include <parserutils/errors.h>
19 #include <parserutils/functypes.h>
20 
22 
23 #define PARSERUTILS_CHARSET_CODEC_NULL (0xffffffffU)
24 
70 
78 
84  struct {
87  } error_mode;
89 
90 
91 /* Create a charset codec */
94 /* Destroy a charset codec */
97 
98 /* Configure a charset codec */
103 
104 /* Encode a chunk of UCS-4 data into a codec's charset */
107  const uint8_t **source, size_t *sourcelen,
108  uint8_t **dest, size_t *destlen);
109 
110 /* Decode a chunk of data in a codec's charset into UCS-4 */
113  const uint8_t **source, size_t *sourcelen,
114  uint8_t **dest, size_t *destlen);
115 
116 /* Reset a charset codec */
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif
parserutils_charset_codec_optparams::error_mode
struct parserutils_charset_codec_optparams::@0 error_mode
Parameters for error mode setting.
parserutils_charset_codec_destroy
parserutils_error parserutils_charset_codec_destroy(parserutils_charset_codec *codec)
Destroy a charset codec.
Definition: codec.c:86
PARSERUTILS_CHARSET_CODEC_ERROR_MODE
@ PARSERUTILS_CHARSET_CODEC_ERROR_MODE
Set codec error mode.
Definition: codec.h:76
errors.h
PARSERUTILS_CHARSET_CODEC_ERROR_STRICT
@ PARSERUTILS_CHARSET_CODEC_ERROR_STRICT
Abort processing if unrepresentable character encountered.
Definition: codec.h:64
parserutils_charset_codec
Core charset codec definition; implementations extend this.
Definition: codec_impl.h:19
parserutils_charset_codec_optparams
union parserutils_charset_codec_optparams parserutils_charset_codec_optparams
Charset codec option parameters.
parserutils_charset_codec_setopt
parserutils_error parserutils_charset_codec_setopt(parserutils_charset_codec *codec, parserutils_charset_codec_opttype type, parserutils_charset_codec_optparams *params)
Configure a charset codec.
Definition: codec.c:107
parserutils_charset_codec_decode
parserutils_error parserutils_charset_codec_decode(parserutils_charset_codec *codec, const uint8_t **source, size_t *sourcelen, uint8_t **dest, size_t *destlen)
Decode a chunk of data in a codec's charset into UCS-4.
Definition: codec.c:163
parserutils_charset_codec_errormode
parserutils_charset_codec_errormode
Charset codec error mode.
Definition: codec.h:62
parserutils_charset_codec_optparams
Charset codec option parameters.
Definition: codec.h:82
functypes.h
parserutils_error
parserutils_error
Definition: errors.h:18
parserutils_charset_codec_optparams::mode
parserutils_charset_codec_errormode mode
The desired error handling mode.
Definition: codec.h:86
parserutils_charset_codec_opttype
parserutils_charset_codec_opttype
Charset codec option types.
Definition: codec.h:74
PARSERUTILS_CHARSET_CODEC_ERROR_LOOSE
@ PARSERUTILS_CHARSET_CODEC_ERROR_LOOSE
Replace unrepresentable characters with single alternate.
Definition: codec.h:66
parserutils_charset_codec_reset
parserutils_error parserutils_charset_codec_reset(parserutils_charset_codec *codec)
Clear a charset codec's encoding state.
Definition: codec.c:182
parserutils_charset_codec_create
parserutils_error parserutils_charset_codec_create(const char *charset, parserutils_charset_codec **codec)
Create a charset codec.
Definition: codec.c:38
PARSERUTILS_CHARSET_CODEC_ERROR_TRANSLIT
@ PARSERUTILS_CHARSET_CODEC_ERROR_TRANSLIT
Transliterate unrepresentable characters, if possible.
Definition: codec.h:68
parserutils_charset_codec_encode
parserutils_error parserutils_charset_codec_encode(parserutils_charset_codec *codec, const uint8_t **source, size_t *sourcelen, uint8_t **dest, size_t *destlen)
Encode a chunk of UCS-4 data into a codec's charset.
Definition: codec.c:136