Ruby  2.5.0dev(2017-10-22revision60238)
encoding.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  encoding.h -
4 
5  $Author: matz $
6  created at: Thu May 24 11:49:41 JST 2007
7 
8  Copyright (C) 2007 Yukihiro Matsumoto
9 
10 **********************************************************************/
11 
12 #ifndef RUBY_ENCODING_H
13 #define RUBY_ENCODING_H 1
14 
15 #if defined(__cplusplus)
16 extern "C" {
17 #if 0
18 } /* satisfy cc-mode */
19 #endif
20 #endif
21 
22 #include <stdarg.h>
23 #include "ruby/ruby.h"
24 #include "ruby/oniguruma.h"
25 
27 
32  /* RUBY_FL_USER10..RUBY_FL_USER16 */),
34 };
35 
36 #define ENCODING_INLINE_MAX RUBY_ENCODING_INLINE_MAX
37 #define ENCODING_SHIFT RUBY_ENCODING_SHIFT
38 #define ENCODING_MASK RUBY_ENCODING_MASK
39 
40 #define RB_ENCODING_SET_INLINED(obj,i) do {\
41  RBASIC(obj)->flags &= ~RUBY_ENCODING_MASK;\
42  RBASIC(obj)->flags |= (VALUE)(i) << RUBY_ENCODING_SHIFT;\
43 } while (0)
44 #define RB_ENCODING_SET(obj,i) rb_enc_set_index((obj), (i))
45 
46 #define RB_ENCODING_GET_INLINED(obj) \
47  (int)((RBASIC(obj)->flags & RUBY_ENCODING_MASK)>>RUBY_ENCODING_SHIFT)
48 #define RB_ENCODING_GET(obj) \
49  (RB_ENCODING_GET_INLINED(obj) != RUBY_ENCODING_INLINE_MAX ? \
50  RB_ENCODING_GET_INLINED(obj) : \
51  rb_enc_get_index(obj))
52 
53 #define RB_ENCODING_IS_ASCII8BIT(obj) (RB_ENCODING_GET_INLINED(obj) == 0)
54 
55 #define ENCODING_SET_INLINED(obj,i) RB_ENCODING_SET_INLINED(obj,i)
56 #define ENCODING_SET(obj,i) RB_ENCODING_SET(obj,i)
57 #define ENCODING_GET_INLINED(obj) RB_ENCODING_GET_INLINED(obj)
58 #define ENCODING_GET(obj) RB_ENCODING_GET(obj)
59 #define ENCODING_IS_ASCII8BIT(obj) RB_ENCODING_IS_ASCII8BIT(obj)
60 #define ENCODING_MAXNAMELEN RUBY_ENCODING_MAXNAMELEN
61 
64  RUBY_ENC_CODERANGE_7BIT = ((int)RUBY_FL_USER8),
65  RUBY_ENC_CODERANGE_VALID = ((int)RUBY_FL_USER9),
66  RUBY_ENC_CODERANGE_BROKEN = ((int)(RUBY_FL_USER8|RUBY_FL_USER9)),
70 };
71 
72 static inline int
73 rb_enc_coderange_clean_p(int cr)
74 {
75  return (cr ^ (cr >> 1)) & RUBY_ENC_CODERANGE_7BIT;
76 }
77 #define RB_ENC_CODERANGE_CLEAN_P(cr) rb_enc_coderange_clean_p(cr)
78 #define RB_ENC_CODERANGE(obj) ((int)RBASIC(obj)->flags & RUBY_ENC_CODERANGE_MASK)
79 #define RB_ENC_CODERANGE_ASCIIONLY(obj) (RB_ENC_CODERANGE(obj) == RUBY_ENC_CODERANGE_7BIT)
80 #define RB_ENC_CODERANGE_SET(obj,cr) (\
81  RBASIC(obj)->flags = \
82  (RBASIC(obj)->flags & ~RUBY_ENC_CODERANGE_MASK) | (cr))
83 #define RB_ENC_CODERANGE_CLEAR(obj) RB_ENC_CODERANGE_SET((obj),0)
84 
85 /* assumed ASCII compatibility */
86 #define RB_ENC_CODERANGE_AND(a, b) \
87  ((a) == RUBY_ENC_CODERANGE_7BIT ? (b) : \
88  (a) != RUBY_ENC_CODERANGE_VALID ? RUBY_ENC_CODERANGE_UNKNOWN : \
89  (b) == RUBY_ENC_CODERANGE_7BIT ? RUBY_ENC_CODERANGE_VALID : (b))
90 
91 #define RB_ENCODING_CODERANGE_SET(obj, encindex, cr) \
92  do { \
93  VALUE rb_encoding_coderange_obj = (obj); \
94  RB_ENCODING_SET(rb_encoding_coderange_obj, (encindex)); \
95  RB_ENC_CODERANGE_SET(rb_encoding_coderange_obj, (cr)); \
96  } while (0)
97 
98 #define ENC_CODERANGE_MASK RUBY_ENC_CODERANGE_MASK
99 #define ENC_CODERANGE_UNKNOWN RUBY_ENC_CODERANGE_UNKNOWN
100 #define ENC_CODERANGE_7BIT RUBY_ENC_CODERANGE_7BIT
101 #define ENC_CODERANGE_VALID RUBY_ENC_CODERANGE_VALID
102 #define ENC_CODERANGE_BROKEN RUBY_ENC_CODERANGE_BROKEN
103 #define ENC_CODERANGE_CLEAN_P(cr) RB_ENC_CODERANGE_CLEAN_P(cr)
104 #define ENC_CODERANGE(obj) RB_ENC_CODERANGE(obj)
105 #define ENC_CODERANGE_ASCIIONLY(obj) RB_ENC_CODERANGE_ASCIIONLY(obj)
106 #define ENC_CODERANGE_SET(obj,cr) RB_ENC_CODERANGE_SET(obj,cr)
107 #define ENC_CODERANGE_CLEAR(obj) RB_ENC_CODERANGE_CLEAR(obj)
108 #define ENC_CODERANGE_AND(a, b) RB_ENC_CODERANGE_AND(a, b)
109 #define ENCODING_CODERANGE_SET(obj, encindex, cr) RB_ENCODING_CODERANGE_SET(obj, encindex, cr)
110 
112 
113 int rb_char_to_option_kcode(int c, int *option, int *kcode);
114 
115 int rb_enc_replicate(const char *, rb_encoding *);
116 int rb_define_dummy_encoding(const char *);
117 PUREFUNC(int rb_enc_dummy_p(rb_encoding *enc));
118 PUREFUNC(int rb_enc_to_index(rb_encoding *enc));
119 int rb_enc_get_index(VALUE obj);
120 void rb_enc_set_index(VALUE obj, int encindex);
121 int rb_enc_find_index(const char *name);
123 rb_encoding *rb_to_encoding(VALUE);
124 rb_encoding *rb_find_encoding(VALUE);
125 rb_encoding *rb_enc_get(VALUE);
126 rb_encoding *rb_enc_compatible(VALUE,VALUE);
127 rb_encoding *rb_enc_check(VALUE,VALUE);
129 VALUE rb_enc_associate(VALUE, rb_encoding*);
130 void rb_enc_copy(VALUE dst, VALUE src);
131 
132 VALUE rb_enc_str_new(const char*, long, rb_encoding*);
133 VALUE rb_enc_str_new_cstr(const char*, rb_encoding*);
134 VALUE rb_enc_str_new_static(const char*, long, rb_encoding*);
135 VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
136 PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
137 VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
138 long rb_enc_strlen(const char*, const char*, rb_encoding*);
139 char* rb_enc_nth(const char*, const char*, long, rb_encoding*);
141 VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
142 VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc);
143 
144 VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *);
145 VALUE rb_str_export_to_enc(VALUE, rb_encoding *);
146 VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
147 VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
148 
149 #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
150 #define rb_enc_str_new(str, len, enc) RB_GNUC_EXTENSION_BLOCK( \
151  (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
152  rb_enc_str_new_static((str), (len), (enc)) : \
153  rb_enc_str_new((str), (len), (enc)) \
154 )
155 #define rb_enc_str_new_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
156  (__builtin_constant_p(str)) ? \
157  rb_enc_str_new_static((str), (long)strlen(str), (enc)) : \
158  rb_enc_str_new_cstr((str), (enc)) \
159 )
160 #endif
161 
162 PRINTF_ARGS(NORETURN(void rb_enc_raise(rb_encoding *, VALUE, const char*, ...)), 3, 4);
163 
164 /* index -> rb_encoding */
165 rb_encoding *rb_enc_from_index(int idx);
166 
167 /* name -> rb_encoding */
168 rb_encoding *rb_enc_find(const char *name);
169 
170 /* rb_encoding * -> name */
171 #define rb_enc_name(enc) (enc)->name
172 
173 /* rb_encoding * -> minlen/maxlen */
174 #define rb_enc_mbminlen(enc) (enc)->min_enc_len
175 #define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
176 
177 /* -> mbclen (no error notification: 0 < ret <= e-p, no exception) */
178 int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc);
179 
180 /* -> mbclen (only for valid encoding) */
181 int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc);
182 
183 /* -> chlen, invalid or needmore */
184 int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc);
185 #define MBCLEN_CHARFOUND_P(ret) ONIGENC_MBCLEN_CHARFOUND_P(ret)
186 #define MBCLEN_CHARFOUND_LEN(ret) ONIGENC_MBCLEN_CHARFOUND_LEN(ret)
187 #define MBCLEN_INVALID_P(ret) ONIGENC_MBCLEN_INVALID_P(ret)
188 #define MBCLEN_NEEDMORE_P(ret) ONIGENC_MBCLEN_NEEDMORE_P(ret)
189 #define MBCLEN_NEEDMORE_LEN(ret) ONIGENC_MBCLEN_NEEDMORE_LEN(ret)
190 
191 /* -> 0x00..0x7f, -1 */
192 int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc);
193 
194 
195 /* -> code (and len) or raise exception */
196 unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc);
197 
198 /* prototype for obsolete function */
199 unsigned int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc);
200 /* overriding macro */
201 #define rb_enc_codepoint(p,e,enc) rb_enc_codepoint_len((p),(e),0,(enc))
202 #define rb_enc_mbc_to_codepoint(p, e, enc) ONIGENC_MBC_TO_CODE((enc),(UChar*)(p),(UChar*)(e))
203 
204 /* -> codelen>0 or raise exception */
205 int rb_enc_codelen(int code, rb_encoding *enc);
206 /* -> 0 for invalid codepoint */
207 int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
208 #define rb_enc_code_to_mbclen(c, enc) ONIGENC_CODE_TO_MBCLEN((enc), (c));
209 
210 /* code,ptr,encoding -> write buf */
211 #define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC((enc),(c),(UChar*)(buf))
212 
213 /* start, ptr, end, encoding -> prev_char */
214 #define rb_enc_prev_char(s,p,e,enc) ((char *)onigenc_get_prev_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
215 /* start, ptr, end, encoding -> next_char */
216 #define rb_enc_left_char_head(s,p,e,enc) ((char *)onigenc_get_left_adjust_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
217 #define rb_enc_right_char_head(s,p,e,enc) ((char *)onigenc_get_right_adjust_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
218 #define rb_enc_step_back(s,p,e,n,enc) ((char *)onigenc_step_back((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e),(int)(n)))
219 
220 /* ptr, ptr, encoding -> newline_or_not */
221 #define rb_enc_is_newline(p,end,enc) ONIGENC_IS_MBC_NEWLINE((enc),(UChar*)(p),(UChar*)(end))
222 
223 #define rb_enc_isctype(c,t,enc) ONIGENC_IS_CODE_CTYPE((enc),(c),(t))
224 #define rb_enc_isascii(c,enc) ONIGENC_IS_CODE_ASCII(c)
225 #define rb_enc_isalpha(c,enc) ONIGENC_IS_CODE_ALPHA((enc),(c))
226 #define rb_enc_islower(c,enc) ONIGENC_IS_CODE_LOWER((enc),(c))
227 #define rb_enc_isupper(c,enc) ONIGENC_IS_CODE_UPPER((enc),(c))
228 #define rb_enc_ispunct(c,enc) ONIGENC_IS_CODE_PUNCT((enc),(c))
229 #define rb_enc_isalnum(c,enc) ONIGENC_IS_CODE_ALNUM((enc),(c))
230 #define rb_enc_isprint(c,enc) ONIGENC_IS_CODE_PRINT((enc),(c))
231 #define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE((enc),(c))
232 #define rb_enc_isdigit(c,enc) ONIGENC_IS_CODE_DIGIT((enc),(c))
233 
234 static inline int
235 rb_enc_asciicompat_inline(rb_encoding *enc)
236 {
237  return rb_enc_mbminlen(enc)==1 && !rb_enc_dummy_p(enc);
238 }
239 #define rb_enc_asciicompat(enc) rb_enc_asciicompat_inline(enc)
240 
241 int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
242 CONSTFUNC(int rb_enc_toupper(int c, rb_encoding *enc));
243 CONSTFUNC(int rb_enc_tolower(int c, rb_encoding *enc));
244 ID rb_intern3(const char*, long, rb_encoding*);
245 ID rb_interned_id_p(const char *, long, rb_encoding *);
246 int rb_enc_symname_p(const char*, rb_encoding*);
247 int rb_enc_symname2_p(const char*, long, rb_encoding*);
249 long rb_str_coderange_scan_restartable(const char*, const char*, rb_encoding*, int*);
251 #define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
252 VALUE rb_enc_from_encoding(rb_encoding *enc);
253 PUREFUNC(int rb_enc_unicode_p(rb_encoding *enc));
254 rb_encoding *rb_ascii8bit_encoding(void);
255 rb_encoding *rb_utf8_encoding(void);
256 rb_encoding *rb_usascii_encoding(void);
257 rb_encoding *rb_locale_encoding(void);
258 rb_encoding *rb_filesystem_encoding(void);
259 rb_encoding *rb_default_external_encoding(void);
260 rb_encoding *rb_default_internal_encoding(void);
261 #ifndef rb_ascii8bit_encindex
263 #endif
264 #ifndef rb_utf8_encindex
265 CONSTFUNC(int rb_utf8_encindex(void));
266 #endif
267 #ifndef rb_usascii_encindex
268 CONSTFUNC(int rb_usascii_encindex(void));
269 #endif
270 int rb_locale_encindex(void);
271 int rb_filesystem_encindex(void);
274 void rb_enc_set_default_external(VALUE encoding);
275 void rb_enc_set_default_internal(VALUE encoding);
277 long rb_memsearch(const void*,long,const void*,long,rb_encoding*);
278 char *rb_enc_path_next(const char *,const char *,rb_encoding*);
279 char *rb_enc_path_skip_prefix(const char *,const char *,rb_encoding*);
280 char *rb_enc_path_last_separator(const char *,const char *,rb_encoding*);
281 char *rb_enc_path_end(const char *,const char *,rb_encoding*);
282 const char *ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc);
283 const char *ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc);
284 ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc);
285 VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc);
286 
288 
289 /* econv stuff */
290 
291 typedef enum {
300 
301 typedef struct rb_econv_t rb_econv_t;
302 
303 VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts);
304 int rb_econv_has_convpath_p(const char* from_encoding, const char* to_encoding);
305 
306 int rb_econv_prepare_options(VALUE opthash, VALUE *ecopts, int ecflags);
307 int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts);
308 
309 rb_econv_t *rb_econv_open(const char *source_encoding, const char *destination_encoding, int ecflags);
310 rb_econv_t *rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts);
311 
312 rb_econv_result_t rb_econv_convert(rb_econv_t *ec,
313  const unsigned char **source_buffer_ptr, const unsigned char *source_buffer_end,
314  unsigned char **destination_buffer_ptr, unsigned char *destination_buffer_end,
315  int flags);
316 void rb_econv_close(rb_econv_t *ec);
317 
318 /* result: 0:success -1:failure */
319 int rb_econv_set_replacement(rb_econv_t *ec, const unsigned char *str, size_t len, const char *encname);
320 
321 /* result: 0:success -1:failure */
322 int rb_econv_decorate_at_first(rb_econv_t *ec, const char *decorator_name);
323 int rb_econv_decorate_at_last(rb_econv_t *ec, const char *decorator_name);
324 
325 VALUE rb_econv_open_exc(const char *senc, const char *denc, int ecflags);
326 
327 /* result: 0:success -1:failure */
329  const unsigned char *str, size_t len, const char *str_encoding);
330 
331 /* encoding that rb_econv_insert_output doesn't need conversion */
333 
334 /* raise an error if the last rb_econv_convert is error */
336 
337 /* returns an exception object or nil */
339 
341 void rb_econv_putback(rb_econv_t *ec, unsigned char *p, int n);
342 
343 /* returns the corresponding ASCII compatible encoding for encname,
344  * or NULL if encname is not ASCII incompatible encoding. */
345 const char *rb_econv_asciicompat_encoding(const char *encname);
346 
348 VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags);
350 VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, VALUE dst, int flags);
351 VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, long bytesize, VALUE dst, int flags);
352 
353 void rb_econv_binmode(rb_econv_t *ec);
354 
356 /* flags for rb_econv_open */
358 
361 
362  RUBY_ECONV_UNDEF_MASK = 0x000000f0,
365 
370 
376 
379 
381 #if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32)
383 #else
384  0,
385 #endif
386 #define ECONV_ERROR_HANDLER_MASK RUBY_ECONV_ERROR_HANDLER_MASK
387 #define ECONV_INVALID_MASK RUBY_ECONV_INVALID_MASK
388 #define ECONV_INVALID_REPLACE RUBY_ECONV_INVALID_REPLACE
389 #define ECONV_UNDEF_MASK RUBY_ECONV_UNDEF_MASK
390 #define ECONV_UNDEF_REPLACE RUBY_ECONV_UNDEF_REPLACE
391 #define ECONV_UNDEF_HEX_CHARREF RUBY_ECONV_UNDEF_HEX_CHARREF
392 #define ECONV_DECORATOR_MASK RUBY_ECONV_DECORATOR_MASK
393 #define ECONV_NEWLINE_DECORATOR_MASK RUBY_ECONV_NEWLINE_DECORATOR_MASK
394 #define ECONV_NEWLINE_DECORATOR_READ_MASK RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK
395 #define ECONV_NEWLINE_DECORATOR_WRITE_MASK RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK
396 #define ECONV_UNIVERSAL_NEWLINE_DECORATOR RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR
397 #define ECONV_CRLF_NEWLINE_DECORATOR RUBY_ECONV_CRLF_NEWLINE_DECORATOR
398 #define ECONV_CR_NEWLINE_DECORATOR RUBY_ECONV_CR_NEWLINE_DECORATOR
399 #define ECONV_XML_TEXT_DECORATOR RUBY_ECONV_XML_TEXT_DECORATOR
400 #define ECONV_XML_ATTR_CONTENT_DECORATOR RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR
401 #define ECONV_STATEFUL_DECORATOR_MASK RUBY_ECONV_STATEFUL_DECORATOR_MASK
402 #define ECONV_XML_ATTR_QUOTE_DECORATOR RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR
403 #define ECONV_DEFAULT_NEWLINE_DECORATOR RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR
404 /* end of flags for rb_econv_open */
405 
406 /* flags for rb_econv_convert */
409 #define ECONV_PARTIAL_INPUT RUBY_ECONV_PARTIAL_INPUT
410 #define ECONV_AFTER_OUTPUT RUBY_ECONV_AFTER_OUTPUT
411 /* end of flags for rb_econv_convert */
413 
415 
416 #if defined(__cplusplus)
417 #if 0
418 { /* satisfy cc-mode */
419 #endif
420 } /* extern "C" { */
421 #endif
422 
423 #endif /* RUBY_ENCODING_H */
int rb_enc_replicate(const char *, rb_encoding *)
Definition: encoding.c:409
VALUE rb_econv_open_exc(const char *senc, const char *denc, int ecflags)
Definition: transcode.c:2033
const char * rb_econv_asciicompat_encoding(const char *encname)
Definition: transcode.c:1782
PUREFUNC(int rb_enc_dummy_p(rb_encoding *enc))
int rb_econv_set_replacement(rb_econv_t *ec, const unsigned char *str, size_t len, const char *encname)
Definition: transcode.c:2195
rb_econv_result_t
Definition: encoding.h:291
RUBY_EXTERN VALUE rb_cEncoding
Definition: encoding.h:287
long rb_str_coderange_scan_restartable(const char *, const char *, rb_encoding *, int *)
Definition: string.c:531
int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc)
rb_econv_t * rb_econv_open(const char *source_encoding, const char *destination_encoding, int ecflags)
Definition: transcode.c:1063
int rb_econv_decorate_at_last(rb_econv_t *ec, const char *decorator_name)
Definition: transcode.c:1922
VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags)
Definition: transcode.c:1868
ruby_econv_flag_type
Definition: encoding.h:355
rb_encoding * rb_find_encoding(VALUE)
Definition: encoding.c:253
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
Definition: symbol.c:984
int rb_enc_dummy_p(rb_encoding *enc)
Definition: encoding.c:132
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *)
Definition: string.c:1008
int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts)
Definition: transcode.c:2569
void rb_econv_close(rb_econv_t *ec)
Definition: transcode.c:1698
rb_encoding * rb_enc_from_index(int idx)
Definition: encoding.c:616
int rb_enc_tolower(int c, rb_encoding *enc)
Definition: encoding.c:1100
int rb_enc_symname2_p(const char *, long, rb_encoding *)
Definition: symbol.c:311
long rb_memsearch(const void *, long, const void *, long, rb_encoding *)
Definition: re.c:244
int rb_usascii_encindex(void)
Definition: encoding.c:1344
char * rb_enc_path_skip_prefix(const char *, const char *, rb_encoding *)
Definition: file.c:3123
VALUE rb_locale_charmap(VALUE klass)
Definition: localeinit.c:90
int rb_enc_str_coderange(VALUE)
Definition: string.c:621
int rb_enc_codelen(int code, rb_encoding *enc)
Definition: encoding.c:1077
rb_encoding * rb_enc_get(VALUE)
Definition: encoding.c:860
rb_encoding * rb_utf8_encoding(void)
Definition: encoding.c:1320
VALUE rb_obj_encoding(VALUE)
Definition: encoding.c:992
ID rb_interned_id_p(const char *, long, rb_encoding *)
VALUE rb_enc_vsprintf(rb_encoding *, const char *, va_list)
Definition: sprintf.c:1400
void rb_enc_copy(VALUE dst, VALUE src)
Definition: encoding.c:978
void rb_enc_set_default_internal(VALUE encoding)
Definition: encoding.c:1561
int rb_define_dummy_encoding(const char *)
Definition: encoding.c:466
void rb_enc_set_index(VALUE obj, int encindex)
Definition: encoding.c:818
int rb_econv_decorate_at_first(rb_econv_t *ec, const char *decorator_name)
Definition: transcode.c:1905
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
Definition: string.c:885
#define NORETURN(x)
Definition: defines.h:34
int rb_enc_symname_p(const char *, rb_encoding *)
Definition: symbol.c:196
VALUE rb_enc_sprintf(rb_encoding *enc, const char *format,...)
Definition: sprintf.c:1433
char * rb_enc_nth(const char *, const char *, long, rb_encoding *)
Definition: string.c:2320
VALUE rb_enc_str_new_static(const char *, long, rb_encoding *)
Definition: string.c:848
int rb_enc_toupper(int c, rb_encoding *enc)
Definition: encoding.c:1094
ruby_coderange_type
Definition: encoding.h:62
ID rb_intern3(const char *, long, rb_encoding *)
Definition: symbol.c:554
VALUE rb_econv_str_append(rb_econv_t *ec, VALUE src, VALUE dst, int flags)
Definition: transcode.c:1862
VALUE rb_econv_make_exception(rb_econv_t *ec)
Definition: transcode.c:4225
void rb_econv_check_error(rb_econv_t *ec)
Definition: transcode.c:4231
int rb_econv_insert_output(rb_econv_t *ec, const unsigned char *str, size_t len, const char *str_encoding)
Definition: transcode.c:1583
int rb_enc_to_index(rb_encoding *enc)
Definition: encoding.c:126
VALUE rb_enc_associate_index(VALUE, int)
Definition: encoding.c:826
int rb_enc_find_index(const char *name)
Definition: encoding.c:704
const char * destination_encoding
Definition: transcode.c:136
rb_encoding * rb_default_external_encoding(void)
Definition: encoding.c:1425
rb_encoding * rb_to_encoding(VALUE)
Definition: encoding.c:246
rb_econv_t * rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts)
Definition: transcode.c:2575
int rb_ascii8bit_encindex(void)
Definition: encoding.c:1314
int rb_econv_has_convpath_p(const char *from_encoding, const char *to_encoding)
Definition: transcode.c:3172
int rb_locale_encindex(void)
Definition: encoding.c:1352
rb_encoding * rb_enc_find(const char *name)
Definition: encoding.c:728
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
Definition: string.c:1002
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
Definition: encoding.c:1032
char * rb_enc_path_next(const char *, const char *, rb_encoding *)
Definition: file.c:3109
VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
Definition: symbol.c:995
#define rb_enc_codepoint(p, e, enc)
Definition: encoding.h:201
#define rb_enc_mbminlen(enc)
Definition: encoding.h:174
CONSTFUNC(int rb_enc_toupper(int c, rb_encoding *enc))
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1008
#define RUBY_EXTERN
Definition: missing.h:77
rb_encoding * rb_usascii_encoding(void)
Definition: encoding.c:1335
VALUE rb_enc_default_external(void)
Definition: encoding.c:1439
int rb_enc_unicode_p(rb_encoding *enc)
Definition: encoding.c:525
#define RUBY_SYMBOL_EXPORT_END
Definition: missing.h:49
unsigned long ID
Definition: ruby.h:86
const char * source_encoding
Definition: transcode.c:135
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc)
Definition: numeric.c:3283
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1020
unsigned long VALUE
Definition: ruby.h:85
char * rb_enc_path_end(const char *, const char *, rb_encoding *)
Definition: file.c:3191
VALUE rb_enc_associate(VALUE, rb_encoding *)
Definition: encoding.c:854
int rb_utf8_encindex(void)
Definition: encoding.c:1329
#define RUBY_SYMBOL_EXPORT_BEGIN
Definition: missing.h:48
VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, VALUE dst, int flags)
Definition: transcode.c:1852
rb_encoding * rb_enc_compatible(VALUE, VALUE)
Definition: encoding.c:962
VALUE rb_enc_from_encoding(rb_encoding *enc)
Definition: encoding.c:117
int rb_char_to_option_kcode(int c, int *option, int *kcode)
Definition: re.c:324
register unsigned int len
Definition: zonetab.h:51
int rb_econv_putbackable(rb_econv_t *ec)
Definition: transcode.c:1738
int rb_enc_get_index(VALUE obj)
Definition: encoding.c:773
unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc)
Definition: encoding.c:1056
int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc)
Definition: encoding.c:1002
long rb_enc_strlen(const char *, const char *, rb_encoding *)
Definition: string.c:1700
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:1442
rb_encoding * rb_filesystem_encoding(void)
Definition: encoding.c:1385
char * rb_enc_path_last_separator(const char *, const char *, rb_encoding *)
Definition: file.c:3157
rb_encoding * rb_locale_encoding(void)
Definition: encoding.c:1370
ruby_encoding_consts
Definition: encoding.h:28
int rb_filesystem_encindex(void)
Definition: encoding.c:1376
VALUE rb_enc_default_internal(void)
Definition: encoding.c:1519
VALUE rb_str_export_to_enc(VALUE, rb_encoding *)
Definition: string.c:1103
PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char *,...), 2, 3)
void rb_enc_raise(rb_encoding *enc, VALUE exc, const char *fmt,...)
Definition: error.c:2271
const OnigEncodingType rb_encoding
Definition: encoding.h:111
rb_encoding * rb_ascii8bit_encoding(void)
Definition: encoding.c:1305
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
Definition: string.c:759
const char * name
Definition: nkf.c:208
rb_encoding * rb_default_internal_encoding(void)
Definition: encoding.c:1510
const char * ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
Definition: file.c:4372
int rb_to_encoding_index(VALUE)
Definition: encoding.c:198
const char * rb_econv_encoding_to_insert_output(rb_econv_t *ec)
Definition: transcode.c:1499
VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, long bytesize, VALUE dst, int flags)
Definition: transcode.c:1809
VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
Definition: transcode.c:2884
void rb_enc_set_default_external(VALUE encoding)
Definition: encoding.c:1477
int rb_enc_str_asciionly_p(VALUE)
Definition: string.c:641
const char * ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc)
Definition: file.c:4172
VALUE rb_enc_reg_new(const char *, long, rb_encoding *, int)
Definition: re.c:2899
int rb_econv_prepare_options(VALUE opthash, VALUE *ecopts, int ecflags)
Definition: transcode.c:2524
void rb_econv_binmode(rb_econv_t *ec)
Definition: transcode.c:1939
VALUE rb_enc_str_new_cstr(const char *, rb_encoding *)
Definition: string.c:794
void rb_econv_putback(rb_econv_t *ec, unsigned char *p, int n)
Definition: transcode.c:1749
#define rb_enc_code_to_mbclen(c, enc)
Definition: encoding.h:208
VALUE rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags)
Definition: transcode.c:1874
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc)
Definition: string.c:2853
rb_encoding * rb_enc_check(VALUE, VALUE)
Definition: encoding.c:879