Ruby: include/ruby/encoding.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

encoding.h
Go to the documentation of this file.
1#ifndef RUBY_ENCODING_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_ENCODING_H 1
13#include "ruby/internal/config.h"
14#include <stdarg.h>
15#include "ruby/ruby.h"
16#include "ruby/oniguruma.h"
17#include "ruby/internal/dllexport.h"
18
19 RBIMPL_SYMBOL_EXPORT_BEGIN()
20
21enum ruby_encoding_consts {
22 RUBY_ENCODING_INLINE_MAX = 127,
23 RUBY_ENCODING_SHIFT = (RUBY_FL_USHIFT+10),
24 RUBY_ENCODING_MASK = (RUBY_ENCODING_INLINE_MAX<<RUBY_ENCODING_SHIFT
25 /* RUBY_FL_USER10..RUBY_FL_USER16 */),
26 RUBY_ENCODING_MAXNAMELEN = 42
27};
28
29#define ENCODING_INLINE_MAX RUBY_ENCODING_INLINE_MAX
30#define ENCODING_SHIFT RUBY_ENCODING_SHIFT
31#define ENCODING_MASK RUBY_ENCODING_MASK
32
33#define RB_ENCODING_SET_INLINED(obj,i) do {\
34 RBASIC(obj)->flags &= ~RUBY_ENCODING_MASK;\
35 RBASIC(obj)->flags |= (VALUE)(i) << RUBY_ENCODING_SHIFT;\
36} while (0)
37#define RB_ENCODING_SET(obj,i) rb_enc_set_index((obj), (i))
38
39#define RB_ENCODING_GET_INLINED(obj) \
40 (int)((RBASIC(obj)->flags & RUBY_ENCODING_MASK)>>RUBY_ENCODING_SHIFT)
41#define RB_ENCODING_GET(obj) \
42 (RB_ENCODING_GET_INLINED(obj) != RUBY_ENCODING_INLINE_MAX ? \
43 RB_ENCODING_GET_INLINED(obj) : \
44 rb_enc_get_index(obj))
45
46#define RB_ENCODING_IS_ASCII8BIT(obj) (RB_ENCODING_GET_INLINED(obj) == 0)
47
48#define ENCODING_SET_INLINED(obj,i) RB_ENCODING_SET_INLINED(obj,i)
49#define ENCODING_SET(obj,i) RB_ENCODING_SET(obj,i)
50#define ENCODING_GET_INLINED(obj) RB_ENCODING_GET_INLINED(obj)
51#define ENCODING_GET(obj) RB_ENCODING_GET(obj)
52#define ENCODING_IS_ASCII8BIT(obj) RB_ENCODING_IS_ASCII8BIT(obj)
53#define ENCODING_MAXNAMELEN RUBY_ENCODING_MAXNAMELEN
54
55 enum ruby_coderange_type {
56 RUBY_ENC_CODERANGE_UNKNOWN = 0,
57 RUBY_ENC_CODERANGE_7BIT = ((int)RUBY_FL_USER8),
58 RUBY_ENC_CODERANGE_VALID = ((int)RUBY_FL_USER9),
59 RUBY_ENC_CODERANGE_BROKEN = ((int)(RUBY_FL_USER8|RUBY_FL_USER9)),
60 RUBY_ENC_CODERANGE_MASK = (RUBY_ENC_CODERANGE_7BIT|
61 RUBY_ENC_CODERANGE_VALID|
62 RUBY_ENC_CODERANGE_BROKEN)
63};
64
65static inline int
66rb_enc_coderange_clean_p(int cr)
67{
68 return (cr ^ (cr >> 1)) & RUBY_ENC_CODERANGE_7BIT;
69}
70#define RB_ENC_CODERANGE_CLEAN_P(cr) rb_enc_coderange_clean_p(cr)
71#define RB_ENC_CODERANGE(obj) ((int)RBASIC(obj)->flags & RUBY_ENC_CODERANGE_MASK)
72#define RB_ENC_CODERANGE_ASCIIONLY(obj) (RB_ENC_CODERANGE(obj) == RUBY_ENC_CODERANGE_7BIT)
73#define RB_ENC_CODERANGE_SET(obj,cr) (\
74 RBASIC(obj)->flags = \
75 (RBASIC(obj)->flags & ~RUBY_ENC_CODERANGE_MASK) | (cr))
76#define RB_ENC_CODERANGE_CLEAR(obj) RB_ENC_CODERANGE_SET((obj),0)
77
78/* assumed ASCII compatibility */
79#define RB_ENC_CODERANGE_AND(a, b) \
80 ((a) == RUBY_ENC_CODERANGE_7BIT ? (b) : \
81 (a) != RUBY_ENC_CODERANGE_VALID ? RUBY_ENC_CODERANGE_UNKNOWN : \
82 (b) == RUBY_ENC_CODERANGE_7BIT ? RUBY_ENC_CODERANGE_VALID : (b))
83
84#define RB_ENCODING_CODERANGE_SET(obj, encindex, cr) \
85 do { \
86 VALUE rb_encoding_coderange_obj = (obj); \
87 RB_ENCODING_SET(rb_encoding_coderange_obj, (encindex)); \
88 RB_ENC_CODERANGE_SET(rb_encoding_coderange_obj, (cr)); \
89 } while (0)
90
91#define ENC_CODERANGE_MASK RUBY_ENC_CODERANGE_MASK
92#define ENC_CODERANGE_UNKNOWN RUBY_ENC_CODERANGE_UNKNOWN
93#define ENC_CODERANGE_7BIT RUBY_ENC_CODERANGE_7BIT
94#define ENC_CODERANGE_VALID RUBY_ENC_CODERANGE_VALID
95#define ENC_CODERANGE_BROKEN RUBY_ENC_CODERANGE_BROKEN
96#define ENC_CODERANGE_CLEAN_P(cr) RB_ENC_CODERANGE_CLEAN_P(cr)
97#define ENC_CODERANGE(obj) RB_ENC_CODERANGE(obj)
98#define ENC_CODERANGE_ASCIIONLY(obj) RB_ENC_CODERANGE_ASCIIONLY(obj)
99#define ENC_CODERANGE_SET(obj,cr) RB_ENC_CODERANGE_SET(obj,cr)
100#define ENC_CODERANGE_CLEAR(obj) RB_ENC_CODERANGE_CLEAR(obj)
101#define ENC_CODERANGE_AND(a, b) RB_ENC_CODERANGE_AND(a, b)
102#define ENCODING_CODERANGE_SET(obj, encindex, cr) RB_ENCODING_CODERANGE_SET(obj, encindex, cr)
103
104 typedef const OnigEncodingType rb_encoding;
105
106int rb_char_to_option_kcode(int c, int *option, int *kcode);
107
108int rb_enc_replicate(const char *, rb_encoding *);
109int rb_define_dummy_encoding(const char *);
110 PUREFUNC(int rb_enc_dummy_p(rb_encoding *enc));
111 PUREFUNC(int rb_enc_to_index(rb_encoding *enc));
112int rb_enc_get_index(VALUE obj);
113void rb_enc_set_index(VALUE obj, int encindex);
114int rb_enc_capable(VALUE obj);
115int rb_enc_find_index(const char *name);
116int rb_enc_alias(const char *alias, const char *orig);
117int rb_to_encoding_index(VALUE);
118 rb_encoding *rb_to_encoding(VALUE);
119 rb_encoding *rb_find_encoding(VALUE);
120 rb_encoding *rb_enc_get(VALUE);
121 rb_encoding *rb_enc_compatible(VALUE,VALUE);
122 rb_encoding *rb_enc_check(VALUE,VALUE);
123 VALUE rb_enc_associate_index(VALUE, int);
124 VALUE rb_enc_associate(VALUE, rb_encoding*);
125void rb_enc_copy(VALUE dst, VALUE src);
126
127 VALUE rb_enc_str_new(const char*, long, rb_encoding*);
128 VALUE rb_enc_str_new_cstr(const char*, rb_encoding*);
129 VALUE rb_enc_str_new_static(const char*, long, rb_encoding*);
130 VALUE rb_enc_interned_str(const char *, long, rb_encoding *);
131 VALUE rb_enc_interned_str_cstr(const char *, rb_encoding *);
132 VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
133 PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
134 VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
135long rb_enc_strlen(const char*, const char*, rb_encoding*);
136char* rb_enc_nth(const char*, const char*, long, rb_encoding*);
137 VALUE rb_obj_encoding(VALUE);
138 VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
139 VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc);
140
141 VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *);
142 VALUE rb_str_export_to_enc(VALUE, rb_encoding *);
143 VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
144 VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
145
146#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
147#define rb_enc_str_new(str, len, enc) RB_GNUC_EXTENSION_BLOCK( \
148 (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
149 rb_enc_str_new_static((str), (len), (enc)) : \
150 rb_enc_str_new((str), (len), (enc)) \
151)
152#define rb_enc_str_new_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
153 (__builtin_constant_p(str)) ? \
154 rb_enc_str_new_static((str), (long)strlen(str), (enc)) : \
155 rb_enc_str_new_cstr((str), (enc)) \
156)
157#endif
158
159 PRINTF_ARGS(NORETURN(void rb_enc_raise(rb_encoding *, VALUE, const char*, ...)), 3, 4);
160
161/* index -> rb_encoding */
162 rb_encoding *rb_enc_from_index(int idx);
163
164/* name -> rb_encoding */
165 rb_encoding *rb_enc_find(const char *name);
166
167/* rb_encoding * -> name */
168#define rb_enc_name(enc) (enc)->name
169
170/* rb_encoding * -> minlen/maxlen */
171#define rb_enc_mbminlen(enc) (enc)->min_enc_len
172#define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
173
174/* -> mbclen (no error notification: 0 < ret <= e-p, no exception) */
175int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc);
176
177/* -> mbclen (only for valid encoding) */
178int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc);
179
180/* -> chlen, invalid or needmore */
181int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc);
182#define MBCLEN_CHARFOUND_P(ret) ONIGENC_MBCLEN_CHARFOUND_P(ret)
183#define MBCLEN_CHARFOUND_LEN(ret) ONIGENC_MBCLEN_CHARFOUND_LEN(ret)
184#define MBCLEN_INVALID_P(ret) ONIGENC_MBCLEN_INVALID_P(ret)
185#define MBCLEN_NEEDMORE_P(ret) ONIGENC_MBCLEN_NEEDMORE_P(ret)
186#define MBCLEN_NEEDMORE_LEN(ret) ONIGENC_MBCLEN_NEEDMORE_LEN(ret)
187
188/* -> 0x00..0x7f, -1 */
189int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc);
190
191
192/* -> code (and len) or raise exception */
193unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc);
194
195/* prototype for obsolete function */
196unsigned int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc);
197/* overriding macro */
198#define rb_enc_codepoint(p,e,enc) rb_enc_codepoint_len((p),(e),0,(enc))
199#define rb_enc_mbc_to_codepoint(p, e, enc) ONIGENC_MBC_TO_CODE((enc),(UChar*)(p),(UChar*)(e))
200
201/* -> codelen>0 or raise exception */
202int rb_enc_codelen(int code, rb_encoding *enc);
203/* -> 0 for invalid codepoint */
204int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
205#define rb_enc_code_to_mbclen(c, enc) ONIGENC_CODE_TO_MBCLEN((enc), (c));
206
207/* code,ptr,encoding -> write buf */
208#define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC((enc),(c),(UChar*)(buf))
209
210/* start, ptr, end, encoding -> prev_char */
211#define rb_enc_prev_char(s,p,e,enc) ((char *)onigenc_get_prev_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
212/* start, ptr, end, encoding -> next_char */
213#define rb_enc_left_char_head(s,p,e,enc) ((char *)onigenc_get_left_adjust_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
214#define rb_enc_right_char_head(s,p,e,enc) ((char *)onigenc_get_right_adjust_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
215#define rb_enc_step_back(s,p,e,n,enc) ((char *)onigenc_step_back((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e),(int)(n)))
216
217/* ptr, ptr, encoding -> newline_or_not */
218#define rb_enc_is_newline(p,end,enc) ONIGENC_IS_MBC_NEWLINE((enc),(UChar*)(p),(UChar*)(end))
219
220#define rb_enc_isctype(c,t,enc) ONIGENC_IS_CODE_CTYPE((enc),(c),(t))
221#define rb_enc_isascii(c,enc) ONIGENC_IS_CODE_ASCII(c)
222#define rb_enc_isalpha(c,enc) ONIGENC_IS_CODE_ALPHA((enc),(c))
223#define rb_enc_islower(c,enc) ONIGENC_IS_CODE_LOWER((enc),(c))
224#define rb_enc_isupper(c,enc) ONIGENC_IS_CODE_UPPER((enc),(c))
225#define rb_enc_ispunct(c,enc) ONIGENC_IS_CODE_PUNCT((enc),(c))
226#define rb_enc_isalnum(c,enc) ONIGENC_IS_CODE_ALNUM((enc),(c))
227#define rb_enc_isprint(c,enc) ONIGENC_IS_CODE_PRINT((enc),(c))
228#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE((enc),(c))
229#define rb_enc_isdigit(c,enc) ONIGENC_IS_CODE_DIGIT((enc),(c))
230
231static inline int
232rb_enc_asciicompat_inline(rb_encoding *enc)
233{
234 return rb_enc_mbminlen(enc)==1 && !rb_enc_dummy_p(enc);
235}
236#define rb_enc_asciicompat(enc) rb_enc_asciicompat_inline(enc)
237
238 int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
239 CONSTFUNC(int rb_enc_toupper(int c, rb_encoding *enc));
240 CONSTFUNC(int rb_enc_tolower(int c, rb_encoding *enc));
241 ID rb_intern3(const char*, long, rb_encoding*);
242 ID rb_interned_id_p(const char *, long, rb_encoding *);
243int rb_enc_symname_p(const char*, rb_encoding*);
244int rb_enc_symname2_p(const char*, long, rb_encoding*);
245int rb_enc_str_coderange(VALUE);
246long rb_str_coderange_scan_restartable(const char*, const char*, rb_encoding*, int*);
247int rb_enc_str_asciionly_p(VALUE);
248#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
249 VALUE rb_enc_from_encoding(rb_encoding *enc);
250 PUREFUNC(int rb_enc_unicode_p(rb_encoding *enc));
251 rb_encoding *rb_ascii8bit_encoding(void);
252 rb_encoding *rb_utf8_encoding(void);
253 rb_encoding *rb_usascii_encoding(void);
254 rb_encoding *rb_locale_encoding(void);
255 rb_encoding *rb_filesystem_encoding(void);
256 rb_encoding *rb_default_external_encoding(void);
257 rb_encoding *rb_default_internal_encoding(void);
258#ifndef rb_ascii8bit_encindex
259 CONSTFUNC(int rb_ascii8bit_encindex(void));
260#endif
261#ifndef rb_utf8_encindex
262 CONSTFUNC(int rb_utf8_encindex(void));
263#endif
264#ifndef rb_usascii_encindex
265 CONSTFUNC(int rb_usascii_encindex(void));
266#endif
267int rb_locale_encindex(void);
268int rb_filesystem_encindex(void);
269 VALUE rb_enc_default_external(void);
270 VALUE rb_enc_default_internal(void);
271void rb_enc_set_default_external(VALUE encoding);
272void rb_enc_set_default_internal(VALUE encoding);
273 VALUE rb_locale_charmap(VALUE klass);
274long rb_memsearch(const void*,long,const void*,long,rb_encoding*);
275char *rb_enc_path_next(const char *,const char *,rb_encoding*);
276char *rb_enc_path_skip_prefix(const char *,const char *,rb_encoding*);
277char *rb_enc_path_last_separator(const char *,const char *,rb_encoding*);
278char *rb_enc_path_end(const char *,const char *,rb_encoding*);
279const char *ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc);
280const char *ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc);
281 ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc);
282 VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc);
283
284 RUBY_EXTERN VALUE rb_cEncoding;
285
286/* econv stuff */
287
288 typedef enum {
289 econv_invalid_byte_sequence,
290 econv_undefined_conversion,
291 econv_destination_buffer_full,
292 econv_source_buffer_empty,
293 econv_finished,
294 econv_after_output,
295 econv_incomplete_input
296} rb_econv_result_t;
297
298 typedef struct rb_econv_t rb_econv_t;
299
300 VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts);
301int rb_econv_has_convpath_p(const char* from_encoding, const char* to_encoding);
302
303int rb_econv_prepare_options(VALUE opthash, VALUE *ecopts, int ecflags);
304int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts);
305
306 rb_econv_t *rb_econv_open(const char *source_encoding, const char *destination_encoding, int ecflags);
307 rb_econv_t *rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts);
308
309 rb_econv_result_t rb_econv_convert(rb_econv_t *ec,
310 const unsigned char **source_buffer_ptr, const unsigned char *source_buffer_end,
311 unsigned char **destination_buffer_ptr, unsigned char *destination_buffer_end,
312 int flags);
313void rb_econv_close(rb_econv_t *ec);
314
315/* result: 0:success -1:failure */
316int rb_econv_set_replacement(rb_econv_t *ec, const unsigned char *str, size_t len, const char *encname);
317
318/* result: 0:success -1:failure */
319int rb_econv_decorate_at_first(rb_econv_t *ec, const char *decorator_name);
320int rb_econv_decorate_at_last(rb_econv_t *ec, const char *decorator_name);
321
322 VALUE rb_econv_open_exc(const char *senc, const char *denc, int ecflags);
323
324/* result: 0:success -1:failure */
325int rb_econv_insert_output(rb_econv_t *ec,
326 const unsigned char *str, size_t len, const char *str_encoding);
327
328/* encoding that rb_econv_insert_output doesn't need conversion */
329const char *rb_econv_encoding_to_insert_output(rb_econv_t *ec);
330
331/* raise an error if the last rb_econv_convert is error */
332void rb_econv_check_error(rb_econv_t *ec);
333
334/* returns an exception object or nil */
335 VALUE rb_econv_make_exception(rb_econv_t *ec);
336
337int rb_econv_putbackable(rb_econv_t *ec);
338void rb_econv_putback(rb_econv_t *ec, unsigned char *p, int n);
339
340/* returns the corresponding ASCII compatible encoding for encname,
341 * or NULL if encname is not ASCII incompatible encoding. */
342const char *rb_econv_asciicompat_encoding(const char *encname);
343
344 VALUE rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags);
345 VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags);
346 VALUE rb_econv_str_append(rb_econv_t *ec, VALUE src, VALUE dst, int flags);
347 VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, VALUE dst, int flags);
348 VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, long bytesize, VALUE dst, int flags);
349
350void rb_econv_binmode(rb_econv_t *ec);
351
352 enum ruby_econv_flag_type {
353/* flags for rb_econv_open */
354 RUBY_ECONV_ERROR_HANDLER_MASK = 0x000000ff,
355
356 RUBY_ECONV_INVALID_MASK = 0x0000000f,
357 RUBY_ECONV_INVALID_REPLACE = 0x00000002,
358
359 RUBY_ECONV_UNDEF_MASK = 0x000000f0,
360 RUBY_ECONV_UNDEF_REPLACE = 0x00000020,
361 RUBY_ECONV_UNDEF_HEX_CHARREF = 0x00000030,
362
363 RUBY_ECONV_DECORATOR_MASK = 0x0000ff00,
364 RUBY_ECONV_NEWLINE_DECORATOR_MASK = 0x00003f00,
365 RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK = 0x00000f00,
366 RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK = 0x00003000,
367
368 RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR = 0x00000100,
369 RUBY_ECONV_CRLF_NEWLINE_DECORATOR = 0x00001000,
370 RUBY_ECONV_CR_NEWLINE_DECORATOR = 0x00002000,
371 RUBY_ECONV_XML_TEXT_DECORATOR = 0x00004000,
372 RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR = 0x00008000,
373
374 RUBY_ECONV_STATEFUL_DECORATOR_MASK = 0x00f00000,
375 RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR = 0x00100000,
376
377 RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR =
378#if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32)
379 RUBY_ECONV_CRLF_NEWLINE_DECORATOR,
380#else
381 0,
382#endif
383#define ECONV_ERROR_HANDLER_MASK RUBY_ECONV_ERROR_HANDLER_MASK
384#define ECONV_INVALID_MASK RUBY_ECONV_INVALID_MASK
385#define ECONV_INVALID_REPLACE RUBY_ECONV_INVALID_REPLACE
386#define ECONV_UNDEF_MASK RUBY_ECONV_UNDEF_MASK
387#define ECONV_UNDEF_REPLACE RUBY_ECONV_UNDEF_REPLACE
388#define ECONV_UNDEF_HEX_CHARREF RUBY_ECONV_UNDEF_HEX_CHARREF
389#define ECONV_DECORATOR_MASK RUBY_ECONV_DECORATOR_MASK
390#define ECONV_NEWLINE_DECORATOR_MASK RUBY_ECONV_NEWLINE_DECORATOR_MASK
391#define ECONV_NEWLINE_DECORATOR_READ_MASK RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK
392#define ECONV_NEWLINE_DECORATOR_WRITE_MASK RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK
393#define ECONV_UNIVERSAL_NEWLINE_DECORATOR RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR
394#define ECONV_CRLF_NEWLINE_DECORATOR RUBY_ECONV_CRLF_NEWLINE_DECORATOR
395#define ECONV_CR_NEWLINE_DECORATOR RUBY_ECONV_CR_NEWLINE_DECORATOR
396#define ECONV_XML_TEXT_DECORATOR RUBY_ECONV_XML_TEXT_DECORATOR
397#define ECONV_XML_ATTR_CONTENT_DECORATOR RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR
398#define ECONV_STATEFUL_DECORATOR_MASK RUBY_ECONV_STATEFUL_DECORATOR_MASK
399#define ECONV_XML_ATTR_QUOTE_DECORATOR RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR
400#define ECONV_DEFAULT_NEWLINE_DECORATOR RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR
401/* end of flags for rb_econv_open */
402
403/* flags for rb_econv_convert */
404 RUBY_ECONV_PARTIAL_INPUT = 0x00010000,
405 RUBY_ECONV_AFTER_OUTPUT = 0x00020000,
406#define ECONV_PARTIAL_INPUT RUBY_ECONV_PARTIAL_INPUT
407#define ECONV_AFTER_OUTPUT RUBY_ECONV_AFTER_OUTPUT
408/* end of flags for rb_econv_convert */
409RUBY_ECONV_FLAGS_PLACEHOLDER};
410
411 RBIMPL_SYMBOL_EXPORT_END()
412
413#endif /* RUBY_ENCODING_H */
CONSTFUNC
#define CONSTFUNC(x)
Definition: attributes.h:51
PUREFUNC
#define PUREFUNC(x)
Definition: attributes.h:54
NORETURN
#define NORETURN(x)
Definition: attributes.h:152
PRINTF_ARGS
#define PRINTF_ARGS(decl, string_index, first_to_check)
Definition: attributes.h:112
ptr
struct RIMemo * ptr
Definition: debug.c:88
dllexport.h
Tewaking visibility of C variables/functions.
RUBY_EXTERN
#define RUBY_EXTERN
Definition: dllexport.h:36
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
len
uint8_t len
Definition: escape.c:17
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
RUBY_FL_USHIFT
@ RUBY_FL_USHIFT
Definition: fl_type.h:150
rb_econv_prepare_options
int rb_econv_prepare_options(VALUE opthash, VALUE *ecopts, int ecflags)
Definition: transcode.c:2526
rb_enc_dummy_p
int rb_enc_dummy_p(rb_encoding *enc)
Definition: encoding.c:203
rb_obj_encoding
VALUE rb_obj_encoding(VALUE)
Definition: encoding.c:1202
ruby_coderange_type
ruby_coderange_type
Definition: encoding.h:55
RUBY_ENC_CODERANGE_MASK
@ RUBY_ENC_CODERANGE_MASK
Definition: encoding.h:60
RUBY_ENC_CODERANGE_VALID
@ RUBY_ENC_CODERANGE_VALID
Definition: encoding.h:58
RUBY_ENC_CODERANGE_7BIT
@ RUBY_ENC_CODERANGE_7BIT
Definition: encoding.h:57
RUBY_ENC_CODERANGE_UNKNOWN
@ RUBY_ENC_CODERANGE_UNKNOWN
Definition: encoding.h:56
RUBY_ENC_CODERANGE_BROKEN
@ RUBY_ENC_CODERANGE_BROKEN
Definition: encoding.h:59
rb_enc_precise_mbclen
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1230
rb_to_encoding
rb_encoding * rb_to_encoding(VALUE)
Definition: encoding.c:329
rb_econv_open_exc
VALUE rb_econv_open_exc(const char *senc, const char *denc, int ecflags)
Definition: transcode.c:2028
rb_enc_get_index
int rb_enc_get_index(VALUE obj)
Definition: encoding.c:977
rb_filesystem_encindex
int rb_filesystem_encindex(void)
Definition: encoding.c:1589
ruby_enc_find_basename
const char * ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc)
Definition: file.c:4589
rb_utf8_encoding
rb_encoding * rb_utf8_encoding(void)
Definition: encoding.c:1537
rb_econv_encoding_to_insert_output
const char * rb_econv_encoding_to_insert_output(rb_econv_t *ec)
Definition: transcode.c:1495
rb_enc_associate
VALUE rb_enc_associate(VALUE, rb_encoding *)
Definition: encoding.c:1064
rb_econv_prepare_opts
int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts)
Definition: transcode.c:2571
rb_str_conv_enc
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
Definition: string.c:1100
rb_ascii8bit_encoding
rb_encoding * rb_ascii8bit_encoding(void)
Definition: encoding.c:1525
rb_enc_str_new_cstr
VALUE rb_enc_str_new_cstr(const char *, rb_encoding *)
Definition: string.c:897
rb_enc_codelen
int rb_enc_codelen(int code, rb_encoding *enc)
Definition: encoding.c:1287
rb_intern3
ID rb_intern3(const char *, long, rb_encoding *)
Definition: symbol.c:714
rb_enc_replicate
int rb_enc_replicate(const char *, rb_encoding *)
Definition: encoding.c:549
rb_encoding
const OnigEncodingType rb_encoding
Definition: encoding.h:104
rb_filesystem_encoding
rb_encoding * rb_filesystem_encoding(void)
Definition: encoding.c:1602
rb_enc_path_end
char * rb_enc_path_end(const char *, const char *, rb_encoding *)
Definition: file.c:3504
ruby_encoding_consts
ruby_encoding_consts
Definition: encoding.h:21
RUBY_ENCODING_MASK
@ RUBY_ENCODING_MASK
Definition: encoding.h:24
RUBY_ENCODING_MAXNAMELEN
@ RUBY_ENCODING_MAXNAMELEN
Definition: encoding.h:26
RUBY_ENCODING_SHIFT
@ RUBY_ENCODING_SHIFT
Definition: encoding.h:23
RUBY_ENCODING_INLINE_MAX
@ RUBY_ENCODING_INLINE_MAX
Definition: encoding.h:22
rb_econv_convert
rb_econv_result_t rb_econv_convert(rb_econv_t *ec, const unsigned char **source_buffer_ptr, const unsigned char *source_buffer_end, unsigned char **destination_buffer_ptr, unsigned char *destination_buffer_end, int flags)
Definition: transcode.c:1438
rb_enc_vsprintf
VALUE rb_enc_vsprintf(rb_encoding *, const char *, va_list)
Definition: sprintf.c:1151
rb_econv_result_t
rb_econv_result_t
Definition: encoding.h:288
econv_incomplete_input
@ econv_incomplete_input
Definition: encoding.h:295
econv_finished
@ econv_finished
Definition: encoding.h:293
econv_undefined_conversion
@ econv_undefined_conversion
Definition: encoding.h:290
econv_after_output
@ econv_after_output
Definition: encoding.h:294
econv_source_buffer_empty
@ econv_source_buffer_empty
Definition: encoding.h:292
econv_destination_buffer_full
@ econv_destination_buffer_full
Definition: encoding.h:291
econv_invalid_byte_sequence
@ econv_invalid_byte_sequence
Definition: encoding.h:289
rb_econv_putbackable
int rb_econv_putbackable(rb_econv_t *ec)
Definition: transcode.c:1734
rb_default_internal_encoding
rb_encoding * rb_default_internal_encoding(void)
Definition: encoding.c:1734
rb_enc_copy
void rb_enc_copy(VALUE dst, VALUE src)
Definition: encoding.c:1188
rb_econv_has_convpath_p
int rb_econv_has_convpath_p(const char *from_encoding, const char *to_encoding)
Definition: transcode.c:3189
rb_enc_interned_str_cstr
VALUE rb_enc_interned_str_cstr(const char *, rb_encoding *)
Definition: string.c:11573
rb_utf8_encindex
int rb_utf8_encindex(void)
Definition: encoding.c:1543
rb_econv_open
rb_econv_t * rb_econv_open(const char *source_encoding, const char *destination_encoding, int ecflags)
Definition: transcode.c:1061
rb_enc_fast_mbclen
int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1212
rb_enc_reg_new
VALUE rb_enc_reg_new(const char *, long, rb_encoding *, int)
Definition: re.c:2946
rb_memsearch
long rb_memsearch(const void *, long, const void *, long, rb_encoding *)
Definition: re.c:247
rb_define_dummy_encoding
int rb_define_dummy_encoding(const char *)
Definition: encoding.c:616
rb_enc_from_index
rb_encoding * rb_enc_from_index(int idx)
Definition: encoding.c:414
rb_ascii8bit_encindex
int rb_ascii8bit_encindex(void)
Definition: encoding.c:1531
rb_enc_symname2_p
int rb_enc_symname2_p(const char *, long, rb_encoding *)
Definition: symbol.c:407
rb_enc_str_coderange
int rb_enc_str_coderange(VALUE)
Definition: string.c:725
rb_econv_str_append
VALUE rb_econv_str_append(rb_econv_t *ec, VALUE src, VALUE dst, int flags)
Definition: transcode.c:1857
rb_enc_codepoint_len
unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc)
Definition: encoding.c:1266
rb_enc_uint_chr
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc)
Definition: numeric.c:3391
rb_enc_unicode_p
int rb_enc_unicode_p(rb_encoding *enc)
Definition: encoding.c:688
rb_enc_to_index
int rb_enc_to_index(rb_encoding *enc)
Definition: encoding.c:197
rb_econv_substr_append
VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, VALUE dst, int flags)
Definition: transcode.c:1848
rb_enc_str_new
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
Definition: string.c:857
rb_find_encoding
rb_encoding * rb_find_encoding(VALUE)
Definition: encoding.c:336
rb_str_conv_enc_opts
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
Definition: string.c:984
rb_enc_symname_p
int rb_enc_symname_p(const char *, rb_encoding *)
Definition: symbol.c:203
rb_enc_set_index
void rb_enc_set_index(VALUE obj, int encindex)
Definition: encoding.c:1028
rb_enc_get
rb_encoding * rb_enc_get(VALUE)
Definition: encoding.c:1070
rb_locale_charmap
VALUE rb_locale_charmap(VALUE klass)
Definition: localeinit.c:91
rb_econv_asciicompat_encoding
const char * rb_econv_asciicompat_encoding(const char *encname)
Definition: transcode.c:1778
rb_enc_set_default_internal
void rb_enc_set_default_internal(VALUE encoding)
Definition: encoding.c:1784
rb_enc_default_external
VALUE rb_enc_default_external(void)
Definition: encoding.c:1661
rb_enc_path_next
char * rb_enc_path_next(const char *, const char *, rb_encoding *)
Definition: file.c:3422
rb_econv_insert_output
int rb_econv_insert_output(rb_econv_t *ec, const unsigned char *str, size_t len, const char *str_encoding)
Definition: transcode.c:1579
rb_econv_str_convert
VALUE rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags)
Definition: transcode.c:1869
rb_econv_open_opts
rb_econv_t * rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts)
Definition: transcode.c:2577
rb_enc_find
rb_encoding * rb_enc_find(const char *name)
Definition: encoding.c:916
rb_enc_from_encoding
VALUE rb_enc_from_encoding(rb_encoding *enc)
Definition: encoding.c:188
rb_enc_str_buf_cat
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc)
Definition: string.c:3072
rb_enc_path_last_separator
char * rb_enc_path_last_separator(const char *, const char *, rb_encoding *)
Definition: file.c:3470
rb_to_encoding_index
int rb_to_encoding_index(VALUE)
Definition: encoding.c:267
rb_enc_tolower
int rb_enc_tolower(int c, rb_encoding *enc)
Definition: encoding.c:1310
rb_econv_decorate_at_last
int rb_econv_decorate_at_last(rb_econv_t *ec, const char *decorator_name)
Definition: transcode.c:1917
rb_enc_str_new_static
VALUE rb_enc_str_new_static(const char *, long, rb_encoding *)
Definition: string.c:951
rb_econv_binmode
void rb_econv_binmode(rb_econv_t *ec)
Definition: transcode.c:1934
rb_enc_codepoint
#define rb_enc_codepoint(p, e, enc)
Definition: encoding.h:198
rb_econv_decorate_at_first
int rb_econv_decorate_at_first(rb_econv_t *ec, const char *decorator_name)
Definition: transcode.c:1900
rb_enc_sprintf
VALUE rb_enc_sprintf(rb_encoding *, const char *,...)
Definition: sprintf.c:1184
rb_str_encode
VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
Definition: transcode.c:2892
rb_default_external_encoding
rb_encoding * rb_default_external_encoding(void)
Definition: encoding.c:1647
rb_enc_str_asciionly_p
int rb_enc_str_asciionly_p(VALUE)
Definition: string.c:739
rb_locale_encindex
int rb_locale_encindex(void)
Definition: encoding.c:1563
rb_econv_make_exception
VALUE rb_econv_make_exception(rb_econv_t *ec)
Definition: transcode.c:4240
rb_char_to_option_kcode
int rb_char_to_option_kcode(int c, int *option, int *kcode)
Definition: re.c:329
rb_cEncoding
VALUE rb_cEncoding
Definition: encoding.c:57
rb_enc_check
rb_encoding * rb_enc_check(VALUE, VALUE)
Definition: encoding.c:1089
rb_enc_code_to_mbclen
#define rb_enc_code_to_mbclen(c, enc)
Definition: encoding.h:205
rb_econv_check_error
void rb_econv_check_error(rb_econv_t *ec)
Definition: transcode.c:4246
ruby_enc_find_extname
const char * ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
Definition: file.c:4786
rb_enc_associate_index
VALUE rb_enc_associate_index(VALUE, int)
Definition: encoding.c:1036
rb_enc_mbclen
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1218
rb_enc_path_skip_prefix
char * rb_enc_path_skip_prefix(const char *, const char *, rb_encoding *)
Definition: file.c:3436
rb_enc_capable
int rb_enc_capable(VALUE obj)
Definition: encoding.c:941
rb_enc_mbminlen
#define rb_enc_mbminlen(enc)
Definition: encoding.h:171
rb_enc_interned_str
VALUE rb_enc_interned_str(const char *, long, rb_encoding *)
Definition: string.c:11562
rb_econv_substr_convert
VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags)
Definition: transcode.c:1863
rb_enc_default_internal
VALUE rb_enc_default_internal(void)
Definition: encoding.c:1743
rb_check_symbol_cstr
VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
Definition: symbol.c:1166
rb_enc_strlen
long rb_enc_strlen(const char *, const char *, rb_encoding *)
Definition: string.c:1887
rb_str_coderange_scan_restartable
long rb_str_coderange_scan_restartable(const char *, const char *, rb_encoding *, int *)
Definition: string.c:617
rb_locale_encoding
rb_encoding * rb_locale_encoding(void)
Definition: encoding.c:1583
rb_enc_compatible
rb_encoding * rb_enc_compatible(VALUE, VALUE)
Definition: encoding.c:1172
rb_enc_toupper
int rb_enc_toupper(int c, rb_encoding *enc)
Definition: encoding.c:1304
rb_usascii_encoding
rb_encoding * rb_usascii_encoding(void)
Definition: encoding.c:1549
rb_enc_set_default_external
void rb_enc_set_default_external(VALUE encoding)
Definition: encoding.c:1701
rb_econv_close
void rb_econv_close(rb_econv_t *ec)
Definition: transcode.c:1694
rb_enc_find_index
int rb_enc_find_index(const char *name)
Definition: encoding.c:879
rb_enc_alias
int rb_enc_alias(const char *alias, const char *orig)
Definition: encoding.c:720
rb_econv_append
VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, long bytesize, VALUE dst, int flags)
Definition: transcode.c:1805
rb_interned_id_p
ID rb_interned_id_p(const char *, long, rb_encoding *)
rb_external_str_new_with_enc
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *)
Definition: string.c:1106
rb_check_id_cstr
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
Definition: symbol.c:1155
rb_econv_putback
void rb_econv_putback(rb_econv_t *ec, unsigned char *p, int n)
Definition: transcode.c:1745
rb_enc_nth
char * rb_enc_nth(const char *, const char *, long, rb_encoding *)
Definition: string.c:2538
rb_econv_set_replacement
int rb_econv_set_replacement(rb_econv_t *ec, const unsigned char *str, size_t len, const char *encname)
Definition: transcode.c:2190
rb_enc_ascget
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
Definition: encoding.c:1242
rb_enc_casefold
int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc)
rb_usascii_encindex
int rb_usascii_encindex(void)
Definition: encoding.c:1555
rb_str_export_to_enc
VALUE rb_str_export_to_enc(VALUE, rb_encoding *)
Definition: string.c:1205
ruby_econv_flag_type
ruby_econv_flag_type
Definition: encoding.h:352
RUBY_ECONV_STATEFUL_DECORATOR_MASK
@ RUBY_ECONV_STATEFUL_DECORATOR_MASK
Definition: encoding.h:374
RUBY_ECONV_CRLF_NEWLINE_DECORATOR
@ RUBY_ECONV_CRLF_NEWLINE_DECORATOR
Definition: encoding.h:369
RUBY_ECONV_AFTER_OUTPUT
@ RUBY_ECONV_AFTER_OUTPUT
Definition: encoding.h:405
RUBY_ECONV_FLAGS_PLACEHOLDER
@ RUBY_ECONV_FLAGS_PLACEHOLDER
Definition: encoding.h:409
RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK
@ RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK
Definition: encoding.h:366
RUBY_ECONV_ERROR_HANDLER_MASK
@ RUBY_ECONV_ERROR_HANDLER_MASK
Definition: encoding.h:354
RUBY_ECONV_UNDEF_MASK
@ RUBY_ECONV_UNDEF_MASK
Definition: encoding.h:359
RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR
@ RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR
Definition: encoding.h:372
RUBY_ECONV_INVALID_REPLACE
@ RUBY_ECONV_INVALID_REPLACE
Definition: encoding.h:357
RUBY_ECONV_XML_TEXT_DECORATOR
@ RUBY_ECONV_XML_TEXT_DECORATOR
Definition: encoding.h:371
RUBY_ECONV_NEWLINE_DECORATOR_MASK
@ RUBY_ECONV_NEWLINE_DECORATOR_MASK
Definition: encoding.h:364
RUBY_ECONV_UNDEF_HEX_CHARREF
@ RUBY_ECONV_UNDEF_HEX_CHARREF
Definition: encoding.h:361
RUBY_ECONV_PARTIAL_INPUT
@ RUBY_ECONV_PARTIAL_INPUT
Definition: encoding.h:404
RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR
@ RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR
Definition: encoding.h:368
RUBY_ECONV_INVALID_MASK
@ RUBY_ECONV_INVALID_MASK
Definition: encoding.h:356
RUBY_ECONV_UNDEF_REPLACE
@ RUBY_ECONV_UNDEF_REPLACE
Definition: encoding.h:360
RUBY_ECONV_DECORATOR_MASK
@ RUBY_ECONV_DECORATOR_MASK
Definition: encoding.h:363
RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR
@ RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR
Definition: encoding.h:375
RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR
@ RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR
Definition: encoding.h:377
RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK
@ RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK
Definition: encoding.h:365
RUBY_ECONV_CR_NEWLINE_DECORATOR
@ RUBY_ECONV_CR_NEWLINE_DECORATOR
Definition: encoding.h:370
config.h
Thin wrapper to ruby/config.h.
int
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
name
const char * name
Definition: nkf.c:208
alias
const char * alias
Definition: nkf.c:1159
oniguruma.h
rb_enc_raise
#define rb_enc_raise
Definition: parser.c:21
ruby.h
stdarg.h
Defines old _.
OnigEncodingTypeST
Definition: onigmo.h:160
code
Definition: inftree9.h:24
rb_econv_t
Definition: transcode.c:120
rb_econv_t::source_encoding
const char * source_encoding
Definition: transcode.c:146
rb_econv_t::destination_encoding
const char * destination_encoding
Definition: transcode.c:147
rb_econv_t::flags
int flags
Definition: transcode.c:121
VALUE
unsigned long VALUE
Definition: value.h:38
ID
unsigned long ID
Definition: value.h:39