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
14#include <stdarg.h>
15#include "ruby/ruby.h"
16#include "ruby/oniguruma.h"
18
20
25 /* RUBY_FL_USER10..RUBY_FL_USER16 */),
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
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)),
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
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 *);
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);
125void rb_enc_copy(VALUE dst, VALUE src);
126
127VALUE rb_enc_str_new(const char*, long, rb_encoding*);
129VALUE rb_enc_str_new_static(const char*, long, rb_encoding*);
130VALUE rb_enc_interned_str(const char *, long, rb_encoding *);
132VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
133PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
134VALUE 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*);
138VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
139VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc);
140
144VALUE 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
159PRINTF_ARGS(NORETURN(void rb_enc_raise(rb_encoding *, VALUE, const char*, ...)), 3, 4);
160
161/* index -> rb_encoding */
163
164/* name -> rb_encoding */
165rb_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 */
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
238int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
239CONSTFUNC(int rb_enc_toupper(int c, rb_encoding *enc));
240CONSTFUNC(int rb_enc_tolower(int c, rb_encoding *enc));
241ID rb_intern3(const char*, long, rb_encoding*);
242ID 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*);
246long rb_str_coderange_scan_restartable(const char*, const char*, rb_encoding*, int*);
248#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
258#ifndef rb_ascii8bit_encindex
260#endif
261#ifndef rb_utf8_encindex
262CONSTFUNC(int rb_utf8_encindex(void));
263#endif
264#ifndef rb_usascii_encindex
266#endif
267int rb_locale_encindex(void);
268int rb_filesystem_encindex(void);
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);
281ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc);
282VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc);
283
285
286/* econv stuff */
287
288typedef enum {
297
298typedef struct rb_econv_t rb_econv_t;
299
300VALUE 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
306rb_econv_t *rb_econv_open(const char *source_encoding, const char *destination_encoding, int ecflags);
307rb_econv_t *rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts);
308
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
322VALUE rb_econv_open_exc(const char *senc, const char *denc, int ecflags);
323
324/* result: 0:success -1:failure */
326 const unsigned char *str, size_t len, const char *str_encoding);
327
328/* encoding that rb_econv_insert_output doesn't need conversion */
330
331/* raise an error if the last rb_econv_convert is error */
333
334/* returns an exception object or nil */
336
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
345VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags);
347VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, VALUE dst, int flags);
348VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, long bytesize, VALUE dst, int flags);
349
351
353/* flags for rb_econv_open */
355
358
362
367
373
376
378#if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32)
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 */
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 */
410
412
413#endif /* RUBY_ENCODING_H */
#define CONSTFUNC(x)
Definition: attributes.h:51
#define PUREFUNC(x)
Definition: attributes.h:54
#define NORETURN(x)
Definition: attributes.h:152
#define PRINTF_ARGS(decl, string_index, first_to_check)
Definition: attributes.h:112
struct RIMemo * ptr
Definition: debug.c:88
Tewaking visibility of C variables/functions.
#define RUBY_EXTERN
Definition: dllexport.h:36
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
uint8_t len
Definition: escape.c:17
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
@ RUBY_FL_USHIFT
Definition: fl_type.h:150
int rb_econv_prepare_options(VALUE opthash, VALUE *ecopts, int ecflags)
Definition: transcode.c:2526
int rb_enc_dummy_p(rb_encoding *enc)
Definition: encoding.c:203
VALUE rb_obj_encoding(VALUE)
Definition: encoding.c:1202
ruby_coderange_type
Definition: encoding.h:55
@ RUBY_ENC_CODERANGE_MASK
Definition: encoding.h:60
@ RUBY_ENC_CODERANGE_VALID
Definition: encoding.h:58
@ RUBY_ENC_CODERANGE_7BIT
Definition: encoding.h:57
@ RUBY_ENC_CODERANGE_UNKNOWN
Definition: encoding.h:56
@ RUBY_ENC_CODERANGE_BROKEN
Definition: encoding.h:59
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1230
rb_encoding * rb_to_encoding(VALUE)
Definition: encoding.c:329
VALUE rb_econv_open_exc(const char *senc, const char *denc, int ecflags)
Definition: transcode.c:2028
int rb_enc_get_index(VALUE obj)
Definition: encoding.c:977
int rb_filesystem_encindex(void)
Definition: encoding.c:1589
const char * ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc)
Definition: file.c:4589
rb_encoding * rb_utf8_encoding(void)
Definition: encoding.c:1537
const char * rb_econv_encoding_to_insert_output(rb_econv_t *ec)
Definition: transcode.c:1495
VALUE rb_enc_associate(VALUE, rb_encoding *)
Definition: encoding.c:1064
int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts)
Definition: transcode.c:2571
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
Definition: string.c:1100
rb_encoding * rb_ascii8bit_encoding(void)
Definition: encoding.c:1525
VALUE rb_enc_str_new_cstr(const char *, rb_encoding *)
Definition: string.c:897
int rb_enc_codelen(int code, rb_encoding *enc)
Definition: encoding.c:1287
ID rb_intern3(const char *, long, rb_encoding *)
Definition: symbol.c:714
int rb_enc_replicate(const char *, rb_encoding *)
Definition: encoding.c:549
const OnigEncodingType rb_encoding
Definition: encoding.h:104
rb_encoding * rb_filesystem_encoding(void)
Definition: encoding.c:1602
char * rb_enc_path_end(const char *, const char *, rb_encoding *)
Definition: file.c:3504
ruby_encoding_consts
Definition: encoding.h:21
@ RUBY_ENCODING_MASK
Definition: encoding.h:24
@ RUBY_ENCODING_MAXNAMELEN
Definition: encoding.h:26
@ RUBY_ENCODING_SHIFT
Definition: encoding.h:23
@ RUBY_ENCODING_INLINE_MAX
Definition: encoding.h:22
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
VALUE rb_enc_vsprintf(rb_encoding *, const char *, va_list)
Definition: sprintf.c:1151
rb_econv_result_t
Definition: encoding.h:288
@ econv_incomplete_input
Definition: encoding.h:295
@ econv_finished
Definition: encoding.h:293
@ econv_undefined_conversion
Definition: encoding.h:290
@ econv_after_output
Definition: encoding.h:294
@ econv_source_buffer_empty
Definition: encoding.h:292
@ econv_destination_buffer_full
Definition: encoding.h:291
@ econv_invalid_byte_sequence
Definition: encoding.h:289
int rb_econv_putbackable(rb_econv_t *ec)
Definition: transcode.c:1734
rb_encoding * rb_default_internal_encoding(void)
Definition: encoding.c:1734
void rb_enc_copy(VALUE dst, VALUE src)
Definition: encoding.c:1188
int rb_econv_has_convpath_p(const char *from_encoding, const char *to_encoding)
Definition: transcode.c:3189
VALUE rb_enc_interned_str_cstr(const char *, rb_encoding *)
Definition: string.c:11573
int rb_utf8_encindex(void)
Definition: encoding.c:1543
rb_econv_t * rb_econv_open(const char *source_encoding, const char *destination_encoding, int ecflags)
Definition: transcode.c:1061
int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1212
VALUE rb_enc_reg_new(const char *, long, rb_encoding *, int)
Definition: re.c:2946
long rb_memsearch(const void *, long, const void *, long, rb_encoding *)
Definition: re.c:247
int rb_define_dummy_encoding(const char *)
Definition: encoding.c:616
rb_encoding * rb_enc_from_index(int idx)
Definition: encoding.c:414
int rb_ascii8bit_encindex(void)
Definition: encoding.c:1531
int rb_enc_symname2_p(const char *, long, rb_encoding *)
Definition: symbol.c:407
int rb_enc_str_coderange(VALUE)
Definition: string.c:725
VALUE rb_econv_str_append(rb_econv_t *ec, VALUE src, VALUE dst, int flags)
Definition: transcode.c:1857
unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc)
Definition: encoding.c:1266
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc)
Definition: numeric.c:3391
int rb_enc_unicode_p(rb_encoding *enc)
Definition: encoding.c:688
int rb_enc_to_index(rb_encoding *enc)
Definition: encoding.c:197
VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, VALUE dst, int flags)
Definition: transcode.c:1848
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
Definition: string.c:857
rb_encoding * rb_find_encoding(VALUE)
Definition: encoding.c:336
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
Definition: string.c:984
int rb_enc_symname_p(const char *, rb_encoding *)
Definition: symbol.c:203
void rb_enc_set_index(VALUE obj, int encindex)
Definition: encoding.c:1028
rb_encoding * rb_enc_get(VALUE)
Definition: encoding.c:1070
VALUE rb_locale_charmap(VALUE klass)
Definition: localeinit.c:91
const char * rb_econv_asciicompat_encoding(const char *encname)
Definition: transcode.c:1778
void rb_enc_set_default_internal(VALUE encoding)
Definition: encoding.c:1784
VALUE rb_enc_default_external(void)
Definition: encoding.c:1661
char * rb_enc_path_next(const char *, const char *, rb_encoding *)
Definition: file.c:3422
int rb_econv_insert_output(rb_econv_t *ec, const unsigned char *str, size_t len, const char *str_encoding)
Definition: transcode.c:1579
VALUE rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags)
Definition: transcode.c:1869
rb_econv_t * rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts)
Definition: transcode.c:2577
rb_encoding * rb_enc_find(const char *name)
Definition: encoding.c:916
VALUE rb_enc_from_encoding(rb_encoding *enc)
Definition: encoding.c:188
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc)
Definition: string.c:3072
char * rb_enc_path_last_separator(const char *, const char *, rb_encoding *)
Definition: file.c:3470
int rb_to_encoding_index(VALUE)
Definition: encoding.c:267
int rb_enc_tolower(int c, rb_encoding *enc)
Definition: encoding.c:1310
int rb_econv_decorate_at_last(rb_econv_t *ec, const char *decorator_name)
Definition: transcode.c:1917
VALUE rb_enc_str_new_static(const char *, long, rb_encoding *)
Definition: string.c:951
void rb_econv_binmode(rb_econv_t *ec)
Definition: transcode.c:1934
#define rb_enc_codepoint(p, e, enc)
Definition: encoding.h:198
int rb_econv_decorate_at_first(rb_econv_t *ec, const char *decorator_name)
Definition: transcode.c:1900
VALUE rb_enc_sprintf(rb_encoding *, const char *,...)
Definition: sprintf.c:1184
VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
Definition: transcode.c:2892
rb_encoding * rb_default_external_encoding(void)
Definition: encoding.c:1647
int rb_enc_str_asciionly_p(VALUE)
Definition: string.c:739
int rb_locale_encindex(void)
Definition: encoding.c:1563
VALUE rb_econv_make_exception(rb_econv_t *ec)
Definition: transcode.c:4240
int rb_char_to_option_kcode(int c, int *option, int *kcode)
Definition: re.c:329
VALUE rb_cEncoding
Definition: encoding.c:57
rb_encoding * rb_enc_check(VALUE, VALUE)
Definition: encoding.c:1089
#define rb_enc_code_to_mbclen(c, enc)
Definition: encoding.h:205
void rb_econv_check_error(rb_econv_t *ec)
Definition: transcode.c:4246
const char * ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
Definition: file.c:4786
VALUE rb_enc_associate_index(VALUE, int)
Definition: encoding.c:1036
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1218
char * rb_enc_path_skip_prefix(const char *, const char *, rb_encoding *)
Definition: file.c:3436
int rb_enc_capable(VALUE obj)
Definition: encoding.c:941
#define rb_enc_mbminlen(enc)
Definition: encoding.h:171
VALUE rb_enc_interned_str(const char *, long, rb_encoding *)
Definition: string.c:11562
VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags)
Definition: transcode.c:1863
VALUE rb_enc_default_internal(void)
Definition: encoding.c:1743
VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
Definition: symbol.c:1166
long rb_enc_strlen(const char *, const char *, rb_encoding *)
Definition: string.c:1887
long rb_str_coderange_scan_restartable(const char *, const char *, rb_encoding *, int *)
Definition: string.c:617
rb_encoding * rb_locale_encoding(void)
Definition: encoding.c:1583
rb_encoding * rb_enc_compatible(VALUE, VALUE)
Definition: encoding.c:1172
int rb_enc_toupper(int c, rb_encoding *enc)
Definition: encoding.c:1304
rb_encoding * rb_usascii_encoding(void)
Definition: encoding.c:1549
void rb_enc_set_default_external(VALUE encoding)
Definition: encoding.c:1701
void rb_econv_close(rb_econv_t *ec)
Definition: transcode.c:1694
int rb_enc_find_index(const char *name)
Definition: encoding.c:879
int rb_enc_alias(const char *alias, const char *orig)
Definition: encoding.c:720
VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, long bytesize, VALUE dst, int flags)
Definition: transcode.c:1805
ID rb_interned_id_p(const char *, long, rb_encoding *)
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *)
Definition: string.c:1106
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
Definition: symbol.c:1155
void rb_econv_putback(rb_econv_t *ec, unsigned char *p, int n)
Definition: transcode.c:1745
char * rb_enc_nth(const char *, const char *, long, rb_encoding *)
Definition: string.c:2538
int rb_econv_set_replacement(rb_econv_t *ec, const unsigned char *str, size_t len, const char *encname)
Definition: transcode.c:2190
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
Definition: encoding.c:1242
int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc)
int rb_usascii_encindex(void)
Definition: encoding.c:1555
VALUE rb_str_export_to_enc(VALUE, rb_encoding *)
Definition: string.c:1205
ruby_econv_flag_type
Definition: encoding.h:352
@ RUBY_ECONV_STATEFUL_DECORATOR_MASK
Definition: encoding.h:374
@ RUBY_ECONV_CRLF_NEWLINE_DECORATOR
Definition: encoding.h:369
@ RUBY_ECONV_AFTER_OUTPUT
Definition: encoding.h:405
@ RUBY_ECONV_FLAGS_PLACEHOLDER
Definition: encoding.h:409
@ RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK
Definition: encoding.h:366
@ RUBY_ECONV_ERROR_HANDLER_MASK
Definition: encoding.h:354
@ RUBY_ECONV_UNDEF_MASK
Definition: encoding.h:359
@ RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR
Definition: encoding.h:372
@ RUBY_ECONV_INVALID_REPLACE
Definition: encoding.h:357
@ RUBY_ECONV_XML_TEXT_DECORATOR
Definition: encoding.h:371
@ RUBY_ECONV_NEWLINE_DECORATOR_MASK
Definition: encoding.h:364
@ RUBY_ECONV_UNDEF_HEX_CHARREF
Definition: encoding.h:361
@ RUBY_ECONV_PARTIAL_INPUT
Definition: encoding.h:404
@ RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR
Definition: encoding.h:368
@ RUBY_ECONV_INVALID_MASK
Definition: encoding.h:356
@ RUBY_ECONV_UNDEF_REPLACE
Definition: encoding.h:360
@ RUBY_ECONV_DECORATOR_MASK
Definition: encoding.h:363
@ RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR
Definition: encoding.h:375
@ RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR
Definition: encoding.h:377
@ RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK
Definition: encoding.h:365
@ RUBY_ECONV_CR_NEWLINE_DECORATOR
Definition: encoding.h:370
Thin wrapper to ruby/config.h.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
const char * name
Definition: nkf.c:208
const char * alias
Definition: nkf.c:1159
#define rb_enc_raise
Definition: parser.c:21
Defines old _.
Definition: inftree9.h:24
const char * source_encoding
Definition: transcode.c:146
const char * destination_encoding
Definition: transcode.c:147
unsigned long VALUE
Definition: value.h:38
unsigned long ID
Definition: value.h:39