Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Functions | Variables
encoding.c File Reference
#include "internal.h"
#include "encindex.h"
#include "regenc.h"
#include <ctype.h>
#include "ruby/util.h"
#include "ruby_assert.h"
Include dependency graph for encoding.c:

Go to the source code of this file.

Data Structures

struct  rb_encoding_entry
 
struct  default_encoding
 

Macros

#define ENC_DEBUG   0
 
#define ENC_ASSERT   (!ENC_DEBUG)?(void)0:assert
 
#define MUST_STRING(str)   (ENC_ASSERT(RB_TYPE_P(str, T_STRING)), str)
 
#define ENC_DUMMY_FLAG   (1<<24)
 
#define ENC_INDEX_MASK   (~(~0U<<24))
 
#define ENC_TO_ENCINDEX(enc)   (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK)
 
#define ENC_DUMMY_P(enc)   ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG)
 
#define ENC_SET_DUMMY(enc)   ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG)
 
#define ENCODING_COUNT   ENCINDEX_BUILTIN_MAX
 
#define UNSPECIFIED_ENCODING   INT_MAX
 
#define ENCODING_NAMELEN_MAX   63
 
#define valid_encoding_name_p(name)   ((name) && strlen(name) <= ENCODING_NAMELEN_MAX)
 
#define enc_autoload_p(enc)   (!rb_enc_mbmaxlen(enc))
 
#define is_data_encoding(obj)   (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type)
 
#define is_obj_encoding(obj)   (RB_TYPE_P((obj), T_DATA) && is_data_encoding(obj))
 
#define ENC_REGISTER(enc)   enc_register_at(ENCINDEX_##enc, rb_enc_name(&OnigEncoding##enc), &OnigEncoding##enc)
 
#define ENCDB_REGISTER(name, enc)   enc_register_at(ENCINDEX_##enc, name, NULL)
 
#define rb_intern(str)   rb_intern_const(str)
 

Typedefs

typedef OnigEncodingType rb_raw_encoding
 

Functions

void rb_enc_init (void)
 
static int load_encoding (const char *name)
 
int rb_data_is_encoding (VALUE obj)
 
static VALUE enc_new (rb_encoding *encoding)
 
static VALUE rb_enc_from_encoding_index (int idx)
 
VALUE rb_enc_from_encoding (rb_encoding *encoding)
 
int rb_enc_to_index (rb_encoding *enc)
 
int rb_enc_dummy_p (rb_encoding *enc)
 
static int enc_autoload (rb_encoding *)
 
static int check_encoding (rb_encoding *enc)
 
static int enc_check_encoding (VALUE obj)
 
 NORETURN (static void not_encoding(VALUE enc))
 
static void not_encoding (VALUE enc)
 
static rb_encodingmust_encoding (VALUE enc)
 
static rb_encodingmust_encindex (int index)
 
int rb_to_encoding_index (VALUE enc)
 
static int str_find_encindex (VALUE enc)
 
static int str_to_encindex (VALUE enc)
 
static rb_encodingstr_to_encoding (VALUE enc)
 
rb_encodingrb_to_encoding (VALUE enc)
 
rb_encodingrb_find_encoding (VALUE enc)
 
void rb_gc_mark_encodings (void)
 
static int enc_table_expand (int newsize)
 
static int enc_register_at (int index, const char *name, rb_encoding *base_encoding)
 
static int enc_register (const char *name, rb_encoding *encoding)
 
static void set_encoding_const (const char *, rb_encoding *)
 
int rb_enc_registered (const char *name)
 
int rb_enc_register (const char *name, rb_encoding *encoding)
 
void rb_encdb_declare (const char *name)
 
static void enc_check_duplication (const char *name)
 
static rb_encodingset_base_encoding (int index, rb_encoding *base)
 
void rb_enc_set_base (const char *name, const char *orig)
 
int rb_enc_set_dummy (int index)
 
int rb_enc_replicate (const char *name, rb_encoding *encoding)
 
static VALUE enc_replicate (VALUE encoding, VALUE name)
 
static int enc_replicate_with_index (const char *name, rb_encoding *origenc, int idx)
 
int rb_encdb_replicate (const char *name, const char *orig)
 
int rb_define_dummy_encoding (const char *name)
 
int rb_encdb_dummy (const char *name)
 
static VALUE enc_dummy_p (VALUE enc)
 
static VALUE enc_ascii_compatible_p (VALUE enc)
 
int rb_enc_unicode_p (rb_encoding *enc)
 
static st_data_t enc_dup_name (st_data_t name)
 
static int enc_alias_internal (const char *alias, int idx)
 
static int enc_alias (const char *alias, int idx)
 
int rb_enc_alias (const char *alias, const char *orig)
 
int rb_encdb_alias (const char *alias, const char *orig)
 
void rb_encdb_set_unicode (int index)
 
rb_encodingrb_enc_from_index (int index)
 
rb_encodingrb_enc_get_from_index (int index)
 
int rb_enc_find_index (const char *name)
 
rb_encodingrb_enc_find (const char *name)
 
static int enc_capable (VALUE obj)
 
ID rb_id_encoding (void)
 
static int enc_get_index_str (VALUE str)
 
int rb_enc_get_index (VALUE obj)
 
static void enc_set_index (VALUE obj, int idx)
 
void rb_enc_set_index (VALUE obj, int idx)
 
VALUE rb_enc_associate_index (VALUE obj, int idx)
 
VALUE rb_enc_associate (VALUE obj, rb_encoding *enc)
 
rb_encodingrb_enc_get (VALUE obj)
 
static rb_encodingenc_compatible_str (VALUE str1, VALUE str2)
 
rb_encodingrb_enc_check_str (VALUE str1, VALUE str2)
 
rb_encodingrb_enc_check (VALUE str1, VALUE str2)
 
static rb_encodingenc_compatible_latter (VALUE str1, VALUE str2, int idx1, int idx2)
 
rb_encodingrb_enc_compatible (VALUE str1, VALUE str2)
 
void rb_enc_copy (VALUE obj1, VALUE obj2)
 
VALUE rb_obj_encoding (VALUE obj)
 
int rb_enc_fast_mbclen (const char *p, const char *e, rb_encoding *enc)
 
int rb_enc_mbclen (const char *p, const char *e, rb_encoding *enc)
 
int rb_enc_precise_mbclen (const char *p, const char *e, rb_encoding *enc)
 
int rb_enc_ascget (const char *p, const char *e, int *len, rb_encoding *enc)
 
unsigned int rb_enc_codepoint_len (const char *p, const char *e, int *len_p, rb_encoding *enc)
 
unsigned int rb_enc_codepoint (const char *p, const char *e, rb_encoding *enc)
 
int rb_enc_codelen (int c, rb_encoding *enc)
 
int rb_enc_code_to_mbclen (int code, rb_encoding *enc)
 
int rb_enc_toupper (int c, rb_encoding *enc)
 
int rb_enc_tolower (int c, rb_encoding *enc)
 
static VALUE enc_inspect (VALUE self)
 
static VALUE enc_name (VALUE self)
 
static int enc_names_i (st_data_t name, st_data_t idx, st_data_t args)
 
static VALUE enc_names (VALUE self)
 
static VALUE enc_list (VALUE klass)
 
static VALUE enc_find (VALUE klass, VALUE enc)
 
static VALUE enc_compatible_p (VALUE klass, VALUE str1, VALUE str2)
 
static VALUE enc_s_alloc (VALUE klass)
 
static VALUE enc_dump (int argc, VALUE *argv, VALUE self)
 
static VALUE enc_load (VALUE klass, VALUE str)
 
static VALUE enc_m_loader (VALUE klass, VALUE str)
 
rb_encodingrb_ascii8bit_encoding (void)
 
int rb_ascii8bit_encindex (void)
 
rb_encodingrb_utf8_encoding (void)
 
int rb_utf8_encindex (void)
 
rb_encodingrb_usascii_encoding (void)
 
int rb_usascii_encindex (void)
 
int rb_locale_charmap_index (void)
 
int rb_locale_encindex (void)
 
rb_encodingrb_locale_encoding (void)
 
int rb_filesystem_encindex (void)
 
rb_encodingrb_filesystem_encoding (void)
 
static int enc_set_default_encoding (struct default_encoding *def, VALUE encoding, const char *name)
 
rb_encodingrb_default_external_encoding (void)
 
VALUE rb_enc_default_external (void)
 
static VALUE get_default_external (VALUE klass)
 
void rb_enc_set_default_external (VALUE encoding)
 
static VALUE set_default_external (VALUE klass, VALUE encoding)
 
rb_encodingrb_default_internal_encoding (void)
 
VALUE rb_enc_default_internal (void)
 
static VALUE get_default_internal (VALUE klass)
 
void rb_enc_set_default_internal (VALUE encoding)
 
static VALUE set_default_internal (VALUE klass, VALUE encoding)
 
static int rb_enc_name_list_i (st_data_t name, st_data_t idx, st_data_t arg)
 
static VALUE rb_enc_name_list (VALUE klass)
 
static int rb_enc_aliases_enc_i (st_data_t name, st_data_t orig, st_data_t arg)
 
static VALUE rb_enc_aliases (VALUE klass)
 
void Init_Encoding (void)
 
void rb_enc_foreach_name (int(*func)(st_data_t name, st_data_t idx, st_data_t arg), st_data_t arg)
 

Variables

static ID id_encoding
 
VALUE rb_cEncoding
 
static VALUE rb_encoding_list
 
struct {
   struct rb_encoding_entry *   list
 
   int   count
 
   int   size
 
   st_table *   names
 
enc_table
 
static const rb_data_type_t encoding_data_type
 
static struct default_encoding default_external = {0}
 
static struct default_encoding default_internal = {-2}
 

Macro Definition Documentation

◆ ENC_ASSERT

#define ENC_ASSERT   (!ENC_DEBUG)?(void)0:assert

Definition at line 22 of file encoding.c.

◆ enc_autoload_p

#define enc_autoload_p (   enc)    (!rb_enc_mbmaxlen(enc))

◆ ENC_DEBUG

#define ENC_DEBUG   0

Definition at line 20 of file encoding.c.

◆ ENC_DUMMY_FLAG

#define ENC_DUMMY_FLAG   (1<<24)

Definition at line 61 of file encoding.c.

◆ ENC_DUMMY_P

#define ENC_DUMMY_P (   enc)    ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG)

◆ ENC_INDEX_MASK

#define ENC_INDEX_MASK   (~(~0U<<24))

Definition at line 62 of file encoding.c.

Referenced by enc_autoload(), must_encindex(), rb_enc_from_index(), and rb_obj_encoding().

◆ ENC_REGISTER

#define ENC_REGISTER (   enc)    enc_register_at(ENCINDEX_##enc, rb_enc_name(&OnigEncoding##enc), &OnigEncoding##enc)

Referenced by rb_enc_init().

◆ ENC_SET_DUMMY

#define ENC_SET_DUMMY (   enc)    ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG)

◆ ENC_TO_ENCINDEX

#define ENC_TO_ENCINDEX (   enc)    (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK)

Definition at line 64 of file encoding.c.

Referenced by enc_autoload(), must_encindex(), rb_enc_from_encoding(), and rb_enc_to_index().

◆ ENCDB_REGISTER

#define ENCDB_REGISTER (   name,
  enc 
)    enc_register_at(ENCINDEX_##enc, name, NULL)

Referenced by rb_enc_init().

◆ ENCODING_COUNT

#define ENCODING_COUNT   ENCINDEX_BUILTIN_MAX

Definition at line 70 of file encoding.c.

Referenced by rb_enc_init().

◆ ENCODING_NAMELEN_MAX

#define ENCODING_NAMELEN_MAX   63

Definition at line 73 of file encoding.c.

Referenced by set_encoding_const().

◆ is_data_encoding

#define is_data_encoding (   obj)    (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type)

Definition at line 86 of file encoding.c.

Referenced by enc_capable(), enc_inspect(), rb_data_is_encoding(), and rb_enc_get_index().

◆ is_obj_encoding

#define is_obj_encoding (   obj)    (RB_TYPE_P((obj), T_DATA) && is_data_encoding(obj))

Definition at line 87 of file encoding.c.

Referenced by enc_check_encoding(), and enc_find().

◆ MUST_STRING

#define MUST_STRING (   str)    (ENC_ASSERT(RB_TYPE_P(str, T_STRING)), str)

Definition at line 23 of file encoding.c.

Referenced by rb_enc_check_str().

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

Referenced by rb_enc_get_index().

◆ UNSPECIFIED_ENCODING

#define UNSPECIFIED_ENCODING   INT_MAX

Definition at line 71 of file encoding.c.

Referenced by enc_find(), enc_set_default_encoding(), and rb_enc_find_index().

◆ valid_encoding_name_p

#define valid_encoding_name_p (   name)    ((name) && strlen(name) <= ENCODING_NAMELEN_MAX)

Definition at line 74 of file encoding.c.

Referenced by enc_alias(), and enc_register_at().

Typedef Documentation

◆ rb_raw_encoding

Definition at line 29 of file encoding.c.

Function Documentation

◆ check_encoding()

static int check_encoding ( rb_encoding enc)
static

Definition at line 140 of file encoding.c.

References enc_autoload(), enc_autoload_p, rb_enc_from_index(), and rb_enc_to_index().

Referenced by enc_check_encoding().

◆ enc_alias()

static int enc_alias ( const char *  alias,
int  idx 
)
static

◆ enc_alias_internal()

static int enc_alias_internal ( const char *  alias,
int  idx 
)
static

Definition at line 541 of file encoding.c.

References enc_dup_name(), enc_table, st_data_t, and st_insert2().

Referenced by enc_alias(), enc_set_default_encoding(), and rb_locale_encindex().

◆ enc_ascii_compatible_p()

static VALUE enc_ascii_compatible_p ( VALUE  enc)
static

Definition at line 516 of file encoding.c.

References must_encoding(), Qfalse, Qtrue, and rb_enc_asciicompat.

Referenced by Init_Encoding().

◆ enc_autoload()

static int enc_autoload ( rb_encoding enc)
static

◆ enc_capable()

static int enc_capable ( VALUE  obj)
inlinestatic

◆ enc_check_duplication()

static void enc_check_duplication ( const char *  name)
static

Definition at line 367 of file encoding.c.

References rb_eArgError, rb_enc_registered(), and rb_raise().

Referenced by rb_enc_alias(), and rb_enc_replicate().

◆ enc_check_encoding()

static int enc_check_encoding ( VALUE  obj)
static

◆ enc_compatible_latter()

static rb_encoding* enc_compatible_latter ( VALUE  str1,
VALUE  str2,
int  idx1,
int  idx2 
)
static

◆ enc_compatible_p()

static VALUE enc_compatible_p ( VALUE  klass,
VALUE  str1,
VALUE  str2 
)
static

◆ enc_compatible_str()

static rb_encoding * enc_compatible_str ( VALUE  str1,
VALUE  str2 
)
static

Definition at line 945 of file encoding.c.

References enc_compatible_latter(), enc_get_index_str(), and rb_enc_from_index().

Referenced by rb_enc_check_str(), and rb_enc_get().

◆ enc_dummy_p()

static VALUE enc_dummy_p ( VALUE  enc)
static

Definition at line 500 of file encoding.c.

References ENC_DUMMY_P, must_encoding(), Qfalse, and Qtrue.

Referenced by Init_Encoding().

◆ enc_dump()

static VALUE enc_dump ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 1284 of file encoding.c.

References enc_name(), and rb_check_arity.

Referenced by Init_Encoding().

◆ enc_dup_name()

static st_data_t enc_dup_name ( st_data_t  name)
static

Definition at line 531 of file encoding.c.

References st_data_t, and strdup.

Referenced by enc_alias_internal().

◆ enc_find()

static VALUE enc_find ( VALUE  klass,
VALUE  enc 
)
static

◆ enc_get_index_str()

static int enc_get_index_str ( VALUE  str)
static

◆ enc_inspect()

static VALUE enc_inspect ( VALUE  self)
static

◆ enc_list()

static VALUE enc_list ( VALUE  klass)
static

Definition at line 1198 of file encoding.c.

References rb_ary_new2, rb_ary_replace(), and rb_encoding_list.

Referenced by Init_Encoding().

◆ enc_load()

static VALUE enc_load ( VALUE  klass,
VALUE  str 
)
static

Definition at line 1292 of file encoding.c.

Referenced by Init_Encoding().

◆ enc_m_loader()

static VALUE enc_m_loader ( VALUE  klass,
VALUE  str 
)
static

Definition at line 1299 of file encoding.c.

References enc_find().

Referenced by Init_Encoding().

◆ enc_name()

static VALUE enc_name ( VALUE  self)
static

◆ enc_names()

static VALUE enc_names ( VALUE  self)
static

Definition at line 1169 of file encoding.c.

References enc_names_i(), enc_table, rb_ary_new2, rb_to_encoding_index(), st_data_t, and st_foreach.

Referenced by Init_Encoding().

◆ enc_names_i()

static int enc_names_i ( st_data_t  name,
st_data_t  idx,
st_data_t  args 
)
static

Definition at line 1148 of file encoding.c.

References OBJ_FREEZE, rb_ary_push(), rb_usascii_str_new2, and ST_CONTINUE.

Referenced by enc_names().

◆ enc_new()

static VALUE enc_new ( rb_encoding encoding)
static

Definition at line 96 of file encoding.c.

References rb_cEncoding, and TypedData_Wrap_Struct.

Referenced by enc_register_at(), and Init_Encoding().

◆ enc_register()

static int enc_register ( const char *  name,
rb_encoding encoding 
)
static

◆ enc_register_at()

static int enc_register_at ( int  index,
const char *  name,
rb_encoding base_encoding 
)
static

◆ enc_replicate()

static VALUE enc_replicate ( VALUE  encoding,
VALUE  name 
)
static

Definition at line 430 of file encoding.c.

References rb_enc_from_encoding_index(), rb_enc_replicate(), rb_to_encoding(), and StringValueCStr.

Referenced by Init_Encoding().

◆ enc_replicate_with_index()

static int enc_replicate_with_index ( const char *  name,
rb_encoding origenc,
int  idx 
)
static

◆ enc_s_alloc()

static VALUE enc_s_alloc ( VALUE  klass)
static

Definition at line 1276 of file encoding.c.

References Qnil, and rb_undefined_alloc().

Referenced by Init_Encoding().

◆ enc_set_default_encoding()

static int enc_set_default_encoding ( struct default_encoding def,
VALUE  encoding,
const char *  name 
)
static

◆ enc_set_index()

static void enc_set_index ( VALUE  obj,
int  idx 
)
static

◆ enc_table_expand()

static int enc_table_expand ( int  newsize)
static

Definition at line 268 of file encoding.c.

References count, enc_table, and realloc.

Referenced by enc_register(), and rb_enc_init().

◆ get_default_external()

static VALUE get_default_external ( VALUE  klass)
static

Definition at line 1471 of file encoding.c.

References rb_enc_default_external().

Referenced by Init_Encoding().

◆ get_default_internal()

static VALUE get_default_internal ( VALUE  klass)
static

Definition at line 1555 of file encoding.c.

References rb_enc_default_internal().

Referenced by Init_Encoding().

◆ Init_Encoding()

void Init_Encoding ( void  )

◆ load_encoding()

static int load_encoding ( const char *  name)
static

◆ must_encindex()

static rb_encoding* must_encindex ( int  index)
static

◆ must_encoding()

static rb_encoding* must_encoding ( VALUE  enc)
static

Definition at line 169 of file encoding.c.

References DATA_PTR, enc_check_encoding(), and not_encoding().

Referenced by enc_ascii_compatible_p(), and enc_dummy_p().

◆ NORETURN()

NORETURN ( static void   not_encodingVALUE enc)

Referenced by enc_check_encoding().

◆ not_encoding()

static void not_encoding ( VALUE  enc)
static

Definition at line 162 of file encoding.c.

References PRIsVALUE, rb_eTypeError, rb_obj_class(), and rb_raise().

Referenced by enc_check_encoding(), enc_inspect(), and must_encoding().

◆ rb_ascii8bit_encindex()

int rb_ascii8bit_encindex ( void  )

◆ rb_ascii8bit_encoding()

rb_encoding* rb_ascii8bit_encoding ( void  )

◆ rb_data_is_encoding()

int rb_data_is_encoding ( VALUE  obj)

Definition at line 90 of file encoding.c.

References is_data_encoding.

Referenced by ibf_dump_object_data().

◆ rb_default_external_encoding()

rb_encoding* rb_default_external_encoding ( void  )

◆ rb_default_internal_encoding()

rb_encoding* rb_default_internal_encoding ( void  )

◆ rb_define_dummy_encoding()

int rb_define_dummy_encoding ( const char *  name)

◆ rb_enc_alias()

int rb_enc_alias ( const char *  alias,
const char *  orig 
)

◆ rb_enc_aliases()

static VALUE rb_enc_aliases ( VALUE  klass)
static

Definition at line 1707 of file encoding.c.

References enc_table, rb_ary_new(), rb_enc_aliases_enc_i(), rb_hash_new(), st_data_t, and st_foreach.

Referenced by Init_Encoding().

◆ rb_enc_aliases_enc_i()

static int rb_enc_aliases_enc_i ( st_data_t  name,
st_data_t  orig,
st_data_t  arg 
)
static

◆ rb_enc_ascget()

int rb_enc_ascget ( const char *  p,
const char *  e,
int *  len,
rb_encoding enc 
)

◆ rb_enc_associate()

VALUE rb_enc_associate ( VALUE  obj,
rb_encoding enc 
)

◆ rb_enc_associate_index()

VALUE rb_enc_associate_index ( VALUE  obj,
int  idx 
)

◆ rb_enc_check()

rb_encoding* rb_enc_check ( VALUE  str1,
VALUE  str2 
)

◆ rb_enc_check_str()

rb_encoding* rb_enc_check_str ( VALUE  str1,
VALUE  str2 
)

◆ rb_enc_code_to_mbclen()

int rb_enc_code_to_mbclen ( int  code,
rb_encoding enc 
)

Definition at line 1088 of file encoding.c.

References ONIGENC_CODE_TO_MBCLEN.

◆ rb_enc_codelen()

int rb_enc_codelen ( int  c,
rb_encoding enc 
)

◆ rb_enc_codepoint()

unsigned int rb_enc_codepoint ( const char *  p,
const char *  e,
rb_encoding enc 
)

Definition at line 1071 of file encoding.c.

References rb_enc_codepoint_len().

◆ rb_enc_codepoint_len()

unsigned int rb_enc_codepoint_len ( const char *  p,
const char *  e,
int *  len_p,
rb_encoding enc 
)

◆ rb_enc_compatible()

rb_encoding* rb_enc_compatible ( VALUE  str1,
VALUE  str2 
)

◆ rb_enc_copy()

void rb_enc_copy ( VALUE  obj1,
VALUE  obj2 
)

◆ rb_enc_default_external()

VALUE rb_enc_default_external ( void  )

Definition at line 1439 of file encoding.c.

References rb_default_external_encoding(), and rb_enc_from_encoding().

Referenced by get_default_external().

◆ rb_enc_default_internal()

VALUE rb_enc_default_internal ( void  )

Definition at line 1519 of file encoding.c.

References rb_default_internal_encoding(), and rb_enc_from_encoding().

Referenced by get_default_internal(), and str_transcode0().

◆ rb_enc_dummy_p()

int rb_enc_dummy_p ( rb_encoding enc)

◆ rb_enc_fast_mbclen()

int rb_enc_fast_mbclen ( const char *  p,
const char *  e,
rb_encoding enc 
)

◆ rb_enc_find()

rb_encoding* rb_enc_find ( const char *  name)

◆ rb_enc_find_index()

int rb_enc_find_index ( const char *  name)

◆ rb_enc_foreach_name()

void rb_enc_foreach_name ( int(*)(st_data_t name, st_data_t idx, st_data_t arg)  func,
st_data_t  arg 
)

Definition at line 1964 of file encoding.c.

References enc_table, func, and st_foreach.

Referenced by Init_w32_codepage(), and remove_invalid_alternative_data().

◆ rb_enc_from_encoding()

VALUE rb_enc_from_encoding ( rb_encoding encoding)

◆ rb_enc_from_encoding_index()

static VALUE rb_enc_from_encoding_index ( int  idx)
static

◆ rb_enc_from_index()

rb_encoding* rb_enc_from_index ( int  index)

◆ rb_enc_get()

rb_encoding* rb_enc_get ( VALUE  obj)

Definition at line 860 of file encoding.c.

References enc_compatible_str(), rb_enc_from_index(), and rb_enc_get_index().

Referenced by attrsetname_to_attr_id(), check_dirname(), check_getline_args(), check_path_encoding(), check_pipe_command(), chompped_length(), convert_encoding(), do_writeconv(), dsymbol_check(), econv_set_replacement(), file_s_fnmatch(), fnmatch_brace(), get_env_cstr(), io_encoding_set(), literal_concat0(), must_be_ascii_compatible(), must_not_be_anonymous(), ole_vstr2wc(), optimized_unescape_html(), parser_prepare(), parser_yyerror(), path_check_0(), path_sub_ext(), preserve_original_state(), push_glob(), rb_econv_open_opts(), rb_econv_prepare_options(), rb_enc_check(), rb_enc_check_str(), rb_file_dirname(), rb_file_expand_path_internal(), rb_file_join(), rb_file_s_basename(), rb_file_s_extname(), rb_gzreader_ungetc(), rb_gzwriter_write(), rb_home_dir_of(), rb_inspect(), rb_io_extract_encoding_option(), rb_io_extract_modeenc(), rb_mod_const_defined(), rb_mod_const_get(), rb_must_asciicompat(), rb_path_to_class(), rb_push_glob(), rb_readlink(), rb_realpath_internal(), rb_reg_check_preprocess(), rb_reg_desc(), rb_reg_error_desc(), rb_reg_initialize_m(), rb_reg_initialize_str(), rb_reg_prepare_enc(), rb_reg_preprocess_dregexp(), rb_reg_quote(), rb_reg_regsub(), rb_reg_s_union(), rb_reg_to_s(), rb_str_cat_conv_enc_opts(), rb_str_conv_enc_opts(), rb_str_ellipsize(), rb_str_enumerate_chars(), rb_str_enumerate_lines(), rb_str_format(), rb_str_intern(), rb_str_symname_type(), rb_string_value_cstr(), rb_thread_setname(), rb_to_encoding_index(), realpath_rec(), reg_enc_error(), reg_fragment_enc_error(), reg_named_capture_assign_gen(), reg_set_source(), ruby__sfvextra(), str_find_encindex(), strio_ungetc(), strio_write(), strscan_aref(), strscan_getch(), sym_check_asciionly(), time_strftime(), transcode_loop(), and update_char_offset().

◆ rb_enc_get_from_index()

rb_encoding* rb_enc_get_from_index ( int  index)

Definition at line 628 of file encoding.c.

References must_encindex().

Referenced by get_actual_encoding(), and str_new_static().

◆ rb_enc_get_index()

int rb_enc_get_index ( VALUE  obj)

◆ rb_enc_init()

void rb_enc_init ( void  )

◆ rb_enc_mbclen()

int rb_enc_mbclen ( const char *  p,
const char *  e,
rb_encoding enc 
)

◆ rb_enc_name_list()

static VALUE rb_enc_name_list ( VALUE  klass)
static

Definition at line 1663 of file encoding.c.

References enc_table, rb_ary_new2, rb_enc_name_list_i(), st_data_t, and st_foreach.

Referenced by Init_Encoding().

◆ rb_enc_name_list_i()

static int rb_enc_name_list_i ( st_data_t  name,
st_data_t  idx,
st_data_t  arg 
)
static

Definition at line 1640 of file encoding.c.

References rb_ary_push(), rb_fstring_cstr(), and ST_CONTINUE.

Referenced by rb_enc_name_list().

◆ rb_enc_precise_mbclen()

int rb_enc_precise_mbclen ( const char *  p,
const char *  e,
rb_encoding enc 
)

◆ rb_enc_register()

int rb_enc_register ( const char *  name,
rb_encoding encoding 
)

◆ rb_enc_registered()

int rb_enc_registered ( const char *  name)

◆ rb_enc_replicate()

int rb_enc_replicate ( const char *  name,
rb_encoding encoding 
)

◆ rb_enc_set_base()

void rb_enc_set_base ( const char *  name,
const char *  orig 
)

Definition at line 389 of file encoding.c.

References rb_enc_from_index(), rb_enc_registered(), and set_base_encoding().

◆ rb_enc_set_default_external()

void rb_enc_set_default_external ( VALUE  encoding)

Definition at line 1477 of file encoding.c.

References enc_set_default_encoding(), NIL_P, rb_eArgError, and rb_raise().

Referenced by process_options(), and set_default_external().

◆ rb_enc_set_default_internal()

void rb_enc_set_default_internal ( VALUE  encoding)

Definition at line 1561 of file encoding.c.

References enc_set_default_encoding().

Referenced by process_options(), and set_default_internal().

◆ rb_enc_set_dummy()

int rb_enc_set_dummy ( int  index)

Definition at line 400 of file encoding.c.

References rb_encoding_entry::enc, ENC_SET_DUMMY, and enc_table.

◆ rb_enc_set_index()

void rb_enc_set_index ( VALUE  obj,
int  idx 
)

Definition at line 818 of file encoding.c.

References enc_set_index(), must_encindex(), and rb_check_frozen.

Referenced by pack_pack(), rb_str_concat_literals(), and str_enc_copy().

◆ rb_enc_to_index()

int rb_enc_to_index ( rb_encoding enc)

◆ rb_enc_tolower()

int rb_enc_tolower ( int  c,
rb_encoding enc 
)

Definition at line 1100 of file encoding.c.

References ONIGENC_ASCII_CODE_TO_LOWER_CASE, and ONIGENC_IS_ASCII_CODE.

◆ rb_enc_toupper()

int rb_enc_toupper ( int  c,
rb_encoding enc 
)

Definition at line 1094 of file encoding.c.

References ONIGENC_ASCII_CODE_TO_UPPER_CASE, and ONIGENC_IS_ASCII_CODE.

Referenced by bracket(), fnmatch_helper(), and rb_str_format().

◆ rb_enc_unicode_p()

int rb_enc_unicode_p ( rb_encoding enc)

Definition at line 525 of file encoding.c.

References ONIGENC_IS_UNICODE, and st_data_t.

Referenced by rb_reg_expr_str(), rb_str_escape(), and rb_str_inspect().

◆ rb_encdb_alias()

int rb_encdb_alias ( const char *  alias,
const char *  orig 
)

Definition at line 572 of file encoding.c.

References enc_alias(), enc_register(), and rb_enc_registered().

Referenced by Init_enc(), and Init_enc_set_filesystem_encoding().

◆ rb_encdb_declare()

void rb_encdb_declare ( const char *  name)

◆ rb_encdb_dummy()

int rb_encdb_dummy ( const char *  name)

◆ rb_encdb_replicate()

int rb_encdb_replicate ( const char *  name,
const char *  orig 
)

◆ rb_encdb_set_unicode()

void rb_encdb_set_unicode ( int  index)

Definition at line 583 of file encoding.c.

References ONIGENC_FLAG_UNICODE, and rb_enc_from_index().

◆ rb_filesystem_encindex()

int rb_filesystem_encindex ( void  )

◆ rb_filesystem_encoding()

rb_encoding* rb_filesystem_encoding ( void  )

◆ rb_find_encoding()

rb_encoding* rb_find_encoding ( VALUE  enc)

Definition at line 253 of file encoding.c.

References enc_check_encoding(), NULL, rb_enc_from_index(), RDATA, and str_find_encindex().

Referenced by find_encoding().

◆ rb_gc_mark_encodings()

void rb_gc_mark_encodings ( void  )

Definition at line 263 of file encoding.c.

Referenced by gc_mark_roots().

◆ rb_id_encoding()

ID rb_id_encoding ( void  )

Definition at line 753 of file encoding.c.

References CONST_ID, and id_encoding.

Referenced by dir_initialize(), enc_get_index_str(), enc_set_index(), Init_IO(), rb_str_init(), and w_encoding().

◆ rb_locale_charmap_index()

int rb_locale_charmap_index ( void  )

Definition at line 92 of file localeinit.c.

References enc_find_index(), and locale_charmap().

Referenced by rb_locale_encindex(), and rb_usascii_encindex().

◆ rb_locale_encindex()

int rb_locale_encindex ( void  )

◆ rb_locale_encoding()

rb_encoding* rb_locale_encoding ( void  )

◆ rb_obj_encoding()

VALUE rb_obj_encoding ( VALUE  obj)

◆ rb_to_encoding()

rb_encoding* rb_to_encoding ( VALUE  enc)

◆ rb_to_encoding_index()

int rb_to_encoding_index ( VALUE  enc)

◆ rb_usascii_encindex()

int rb_usascii_encindex ( void  )

◆ rb_usascii_encoding()

rb_encoding* rb_usascii_encoding ( void  )

◆ rb_utf8_encindex()

int rb_utf8_encindex ( void  )

◆ rb_utf8_encoding()

rb_encoding* rb_utf8_encoding ( void  )

◆ set_base_encoding()

static rb_encoding* set_base_encoding ( int  index,
rb_encoding base 
)
static

◆ set_default_external()

static VALUE set_default_external ( VALUE  klass,
VALUE  encoding 
)
static

Definition at line 1500 of file encoding.c.

References rb_enc_set_default_external(), and rb_warning().

Referenced by Init_Encoding().

◆ set_default_internal()

static VALUE set_default_internal ( VALUE  klass,
VALUE  encoding 
)
static

Definition at line 1581 of file encoding.c.

References rb_enc_set_default_internal(), and rb_warning().

Referenced by Init_Encoding().

◆ set_encoding_const()

static void set_encoding_const ( const char *  name,
rb_encoding enc 
)
static

◆ str_find_encindex()

static int str_find_encindex ( VALUE  enc)
static

◆ str_to_encindex()

static int str_to_encindex ( VALUE  enc)
static

Definition at line 230 of file encoding.c.

References PRIsVALUE, rb_eArgError, rb_raise(), and str_find_encindex().

Referenced by enc_find(), and str_to_encoding().

◆ str_to_encoding()

static rb_encoding* str_to_encoding ( VALUE  enc)
static

Definition at line 240 of file encoding.c.

References rb_enc_from_index(), and str_to_encindex().

Referenced by rb_to_encoding().

Variable Documentation

◆ count

int count

◆ default_external

struct default_encoding default_external = {0}
static

Definition at line 1395 of file encoding.c.

◆ default_internal

struct default_encoding default_internal = {-2}
static

Definition at line 1507 of file encoding.c.

◆ enc_table

struct { ... } enc_table

◆ encoding_data_type

const rb_data_type_t encoding_data_type
static
Initial value:
= {
"encoding",
{0, 0, 0,},
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145

Definition at line 80 of file encoding.c.

◆ id_encoding

ID id_encoding
static

Definition at line 44 of file encoding.c.

Referenced by rb_id_encoding().

◆ list

struct rb_encoding_entry* list

◆ names

st_table* names

Definition at line 58 of file encoding.c.

Referenced by make_hostent_internal(), match_inspect(), and sock_s_gethostbyaddr().

◆ rb_cEncoding

VALUE rb_cEncoding

◆ rb_encoding_list

VALUE rb_encoding_list
static

Definition at line 46 of file encoding.c.

Referenced by enc_list(), enc_register_at(), Init_Encoding(), and rb_enc_from_encoding_index().

◆ size

int size

Definition at line 57 of file encoding.c.

Referenced by add_code_range_to_buf0(), allocate_to_register_or_stack(), allocate_to_stack(), argf_memsize(), backtrace_each(), backtrace_to_location_ary(), backtrace_to_str_ary(), BSD_vfprintf(), change_mparam(), check_machine_stack_size(), closure_memsize(), compile_data_alloc(), console_echo_p(), cont_capture(), cont_memsize(), cont_restore_thread(), cont_save_machine_stack(), date_strftime_alloc(), dlmallopt(), dln_find_exe_r(), dln_find_file_r(), dln_strerror(), dump_node(), each_cons_i(), each_slice_i(), enum_cycle_size(), enum_each_cons(), enum_each_cons_size(), enum_each_slice(), enum_each_slice_size(), enum_size_over_p(), ffi_call(), ffi_check_struct_type(), ffi_closure_call_SYSV(), ffi_closure_helper(), ffi_closure_helper_SYSV(), ffi_closure_osf_inner(), ffi_closure_sparc_inner_v8(), ffi_closure_sparc_inner_v9(), ffi_closure_SYSV_inner(), ffi_closure_unix_inner(), ffi_prep_args(), ffi_prep_args_VFP(), ffi_prep_cif_machdep(), ffi_prep_cif_sysv_core(), ffi_prep_closure_inner(), ffi_prep_incoming_args_VFP(), fiber_memsize(), finish_overlapped(), finish_overlapped_socket(), flush_icache(), flush_range(), fmt_setup(), function_memsize(), gc_mark_roots(), get_line_info(), getifaddrs(), gzfile_memsize(), heap_pages_expand_sorted_to(), ialloc(), ibf_dump_id_list(), ibf_dump_iseq_list(), ibf_dump_local_table(), ibf_dump_memsize(), ibf_dump_object_list(), ibf_load_catch_table(), ibf_load_local_table(), id2key(), internal_memalign(), io_fread(), iseq_memsize(), iseq_optimize(), iseq_set_local_table(), iseq_specialized_instruction(), limit_by_enum_size(), make_readconv(), mark_stack_size(), memsize_dbm(), mmrot3_(), mmswap_(), new_callinfo(), obj_memsize_of(), objspace_malloc_fixup(), objspace_malloc_prepare(), objspace_xcalloc(), ole_cp2encoding(), ole_rec2variant(), ole_wc2mb_alloc(), olerecord_size(), onig_memsize(), onig_region_memsize(), onig_set_match_stack_limit_size(), onigenc_with_ascii_strnicmp(), overlapped_socket_io(), param_keyword_size(), parser_memsize(), rb_alloc_tmp_buffer2(), rb_ary_initialize(), rb_big2str_generic(), rb_econv_memsize(), rb_exec_async_signal_safe(), rb_file_expand_path_internal(), rb_hash_hash(), rb_hash_keys(), rb_hash_values(), rb_io_memsize(), rb_iseq_disasm(), rb_node_memsize(), rb_objspace_reachable_objects_from_root(), rb_readlink(), rb_stat_s(), rb_str_justify(), rb_struct_new(), rb_thread_priority_set(), rb_transcoding_memsize(), rb_vmdebug_thread_dump_state(), rb_w32_read(), rb_w32_reparse_symlink_p(), rb_w32_write(), rb_zstream_set_avail_out(), recvmsg(), reg_get_val(), release_unused_segments(), remove_invalid_alternative_data(), replace_to_long_name(), ruby_getcwd(), ruby_qsort(), sendmsg(), st_general_keys(), st_general_values(), State_memsize(), thread_memsize(), unset_addr_list_add(), unset_addr_list_init(), vm_memsize(), w32_readlink(), wlstati64(), wmap_aset_update(), wmap_final_func(), wmap_finalize(), wmap_memsize(), wstati64(), yaml_emitter_set_output_string(), yaml_malloc(), yaml_parser_set_input_string(), yaml_parser_update_buffer(), yaml_realloc(), yaml_string_read_handler(), and yaml_string_write_handler().