Ruby: include/ruby/internal/encoding/encoding.h Source File

Ruby 3.4.8p72 (2025-12-17 revision 995b59f66677d44767ce9faac6957e5543617ff9)

encoding.h
Go to the documentation of this file.
1#ifndef RUBY_INTERNAL_ENCODING_ENCODING_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_INTERNAL_ENCODING_ENCODING_H
24#include "ruby/oniguruma.h"
25#include "ruby/internal/attr/const.h"
26#include "ruby/internal/attr/deprecated.h"
27#include "ruby/internal/attr/noalias.h"
28#include "ruby/internal/attr/pure.h"
29#include "ruby/internal/attr/returns_nonnull.h"
30#include "ruby/internal/dllexport.h"
31#include "ruby/internal/encoding/coderange.h"
32#include "ruby/internal/value.h"
33#include "ruby/internal/core/rbasic.h"
34#include "ruby/internal/fl_type.h"
35
36 RBIMPL_SYMBOL_EXPORT_BEGIN()
37
38
43 RUBY_EXTERN VALUE rb_cEncoding;
44
51enum ruby_encoding_consts {
52
54 RUBY_ENCODING_INLINE_MAX = 127,
55
57 RUBY_ENCODING_SHIFT = (RUBY_FL_USHIFT+10),
58
60 RUBY_ENCODING_MASK = (RUBY_ENCODING_INLINE_MAX<<RUBY_ENCODING_SHIFT
61 /* RUBY_FL_USER10..RUBY_FL_USER16 */),
62
64 RUBY_ENCODING_MAXNAMELEN = 42
65};
66
67#define ENCODING_INLINE_MAX RUBY_ENCODING_INLINE_MAX
68#define ENCODING_SHIFT RUBY_ENCODING_SHIFT
69#define ENCODING_MASK RUBY_ENCODING_MASK
80static inline void
81RB_ENCODING_SET_INLINED(VALUE obj, int encindex)
82{
83 VALUE f = /* upcast */ RBIMPL_CAST((VALUE)encindex);
84
85 f <<= RUBY_ENCODING_SHIFT;
86 RB_FL_UNSET_RAW(obj, RUBY_ENCODING_MASK);
87 RB_FL_SET_RAW(obj, f);
88}
89
98static inline int
99RB_ENCODING_GET_INLINED(VALUE obj)
100{
101 VALUE ret = RB_FL_TEST_RAW(obj, RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT;
102
103 return RBIMPL_CAST((int)ret);
104}
105
106#define ENCODING_SET_INLINED(obj,i) RB_ENCODING_SET_INLINED(obj,i)
107#define ENCODING_SET(obj,i) RB_ENCODING_SET(obj,i)
108#define ENCODING_GET_INLINED(obj) RB_ENCODING_GET_INLINED(obj)
109#define ENCODING_GET(obj) RB_ENCODING_GET(obj)
110#define ENCODING_IS_ASCII8BIT(obj) RB_ENCODING_IS_ASCII8BIT(obj)
111#define ENCODING_MAXNAMELEN RUBY_ENCODING_MAXNAMELEN
117 typedef const OnigEncodingType rb_encoding;
118
119 RBIMPL_ATTR_NOALIAS()
140int rb_char_to_option_kcode(int c, int *option, int *kcode);
141
153int rb_define_dummy_encoding(const char *name);
154
155 RBIMPL_ATTR_PURE()
163int rb_enc_dummy_p(rb_encoding *enc);
164
165 RBIMPL_ATTR_PURE()
175int rb_enc_to_index(rb_encoding *enc);
176
184int rb_enc_get_index(VALUE obj);
185
194static inline int
195RB_ENCODING_GET(VALUE obj)
196{
197 int encindex = RB_ENCODING_GET_INLINED(obj);
198
199 if (encindex == RUBY_ENCODING_INLINE_MAX) {
200 return rb_enc_get_index(obj);
201 }
202 else {
203 return encindex;
204 }
205}
206
217void rb_enc_set_index(VALUE obj, int encindex);
218
220static inline void
221RB_ENCODING_SET(VALUE obj, int encindex)
222{
223 rb_enc_set_index(obj, encindex);
224}
225
237static inline void
238RB_ENCODING_CODERANGE_SET(VALUE obj, int encindex, enum ruby_coderange_type cr)
239{
240 RB_ENCODING_SET(obj, encindex);
241 RB_ENC_CODERANGE_SET(obj, cr);
242}
243
244 RBIMPL_ATTR_PURE()
252int rb_enc_capable(VALUE obj);
253
262int rb_enc_find_index(const char *name);
263
277int rb_enc_alias(const char *alias, const char *orig);
278
287int rb_to_encoding_index(VALUE obj);
288
298 rb_encoding *rb_to_encoding(VALUE obj);
299
308 rb_encoding *rb_find_encoding(VALUE obj);
309
317 rb_encoding *rb_enc_get(VALUE obj);
318
331 rb_encoding *rb_enc_compatible(VALUE str1, VALUE str2);
332
343 rb_encoding *rb_enc_check(VALUE str1,VALUE str2);
344
359 VALUE rb_enc_associate_index(VALUE obj, int encindex);
360
372 VALUE rb_enc_associate(VALUE obj, rb_encoding *enc);
373
387void rb_enc_copy(VALUE dst, VALUE src);
388
389
398 rb_encoding *rb_enc_from_index(int idx);
399
408 rb_encoding *rb_enc_find(const char *name);
409
416static inline const char *
417rb_enc_name(rb_encoding *enc)
418{
419 return enc->name;
420}
421
431static inline int
432rb_enc_mbminlen(rb_encoding *enc)
433{
434 return enc->min_enc_len;
435}
436
446static inline int
447rb_enc_mbmaxlen(rb_encoding *enc)
448{
449 return enc->max_enc_len;
450}
451
468int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc);
469
486int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc);
487
514int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc);
515
516#define MBCLEN_CHARFOUND_P(ret) ONIGENC_MBCLEN_CHARFOUND_P(ret)
517#define MBCLEN_CHARFOUND_LEN(ret) ONIGENC_MBCLEN_CHARFOUND_LEN(ret)
518#define MBCLEN_INVALID_P(ret) ONIGENC_MBCLEN_INVALID_P(ret)
519#define MBCLEN_NEEDMORE_P(ret) ONIGENC_MBCLEN_NEEDMORE_P(ret)
520#define MBCLEN_NEEDMORE_LEN(ret) ONIGENC_MBCLEN_NEEDMORE_LEN(ret)
536int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc);
537
550unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc);
551
570static inline unsigned int
571rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc)
572{
573 return rb_enc_codepoint_len(p, e, 0, enc);
574 /* ^^^
575 * This can be `NULL` in C, `nullptr` in C++, and `0` for both.
576 * We choose the most portable one here.
577 */
578}
579
580
590static inline OnigCodePoint
591rb_enc_mbc_to_codepoint(const char *p, const char *e, rb_encoding *enc)
592{
593 const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p);
594 const OnigUChar *ue = RBIMPL_CAST((const OnigUChar *)e);
595
596 return ONIGENC_MBC_TO_CODE(enc, up, ue);
597}
598
608int rb_enc_codelen(int code, rb_encoding *enc);
609
618static inline int
619rb_enc_code_to_mbclen(int c, rb_encoding *enc)
620{
621 OnigCodePoint uc = RBIMPL_CAST((OnigCodePoint)c);
622
623 return ONIGENC_CODE_TO_MBCLEN(enc, uc);
624}
625
642static inline int
643rb_enc_mbcput(unsigned int c, void *buf, rb_encoding *enc)
644{
645 OnigCodePoint uc = RBIMPL_CAST((OnigCodePoint)c);
646 OnigUChar *ubuf = RBIMPL_CAST((OnigUChar *)buf);
647
648 return ONIGENC_CODE_TO_MBC(enc, uc, ubuf);
649}
650
661static inline char *
662rb_enc_prev_char(const char *s, const char *p, const char *e, rb_encoding *enc)
663{
664 const OnigUChar *us = RBIMPL_CAST((const OnigUChar *)s);
665 const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p);
666 const OnigUChar *ue = RBIMPL_CAST((const OnigUChar *)e);
667 OnigUChar *ur = onigenc_get_prev_char_head(enc, us, up, ue);
668
669 return RBIMPL_CAST((char *)ur);
670}
671
682static inline char *
683rb_enc_left_char_head(const char *s, const char *p, const char *e, rb_encoding *enc)
684{
685 const OnigUChar *us = RBIMPL_CAST((const OnigUChar *)s);
686 const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p);
687 const OnigUChar *ue = RBIMPL_CAST((const OnigUChar *)e);
688 OnigUChar *ur = onigenc_get_left_adjust_char_head(enc, us, up, ue);
689
690 return RBIMPL_CAST((char *)ur);
691}
692
703static inline char *
704rb_enc_right_char_head(const char *s, const char *p, const char *e, rb_encoding *enc)
705{
706 const OnigUChar *us = RBIMPL_CAST((const OnigUChar *)s);
707 const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p);
708 const OnigUChar *ue = RBIMPL_CAST((const OnigUChar *)e);
709 OnigUChar *ur = onigenc_get_right_adjust_char_head(enc, us, up, ue);
710
711 return RBIMPL_CAST((char *)ur);
712}
713
725static inline char *
726rb_enc_step_back(const char *s, const char *p, const char *e, int n, rb_encoding *enc)
727{
728 const OnigUChar *us = RBIMPL_CAST((const OnigUChar *)s);
729 const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p);
730 const OnigUChar *ue = RBIMPL_CAST((const OnigUChar *)e);
731 const OnigUChar *ur = onigenc_step_back(enc, us, up, ue, n);
732
733 return RBIMPL_CAST((char *)ur);
734}
735
746static inline int
747rb_enc_asciicompat_inline(rb_encoding *enc)
748{
749 return rb_enc_mbminlen(enc)==1 && !rb_enc_dummy_p(enc);
750}
751
767static inline bool
768rb_enc_asciicompat(rb_encoding *enc)
769{
770 if (rb_enc_mbminlen(enc) != 1) {
771 return false;
772 }
773 else if (rb_enc_dummy_p(enc)) {
774 return false;
775 }
776 else {
777 return true;
778 }
779}
780
788static inline bool
789rb_enc_str_asciicompat_p(VALUE str)
790{
791 rb_encoding *enc = rb_enc_get(str);
792
793 return rb_enc_asciicompat(enc);
794}
795
804 VALUE rb_enc_from_encoding(rb_encoding *enc);
805
806 RBIMPL_ATTR_PURE()
821int rb_enc_unicode_p(rb_encoding *enc);
822
823 RBIMPL_ATTR_RETURNS_NONNULL()
833 rb_encoding *rb_ascii8bit_encoding(void);
834
835 RBIMPL_ATTR_RETURNS_NONNULL()
845 rb_encoding *rb_utf8_encoding(void);
846
847 RBIMPL_ATTR_RETURNS_NONNULL()
857 rb_encoding *rb_usascii_encoding(void);
858
871 rb_encoding *rb_locale_encoding(void);
872
882 rb_encoding *rb_filesystem_encoding(void);
883
891 rb_encoding *rb_default_external_encoding(void);
892
900 rb_encoding *rb_default_internal_encoding(void);
901
902#ifndef rb_ascii8bit_encindex
903 RBIMPL_ATTR_CONST()
914int rb_ascii8bit_encindex(void);
915#endif
916
926static inline bool
927RB_ENCODING_IS_ASCII8BIT(VALUE obj)
928{
929 return RB_ENCODING_GET_INLINED(obj) == rb_ascii8bit_encindex();
930}
931
932#ifndef rb_utf8_encindex
933 RBIMPL_ATTR_CONST()
940int rb_utf8_encindex(void);
941#endif
942
943#ifndef rb_usascii_encindex
944 RBIMPL_ATTR_CONST()
951int rb_usascii_encindex(void);
952#endif
953
960int rb_locale_encindex(void);
961
968int rb_filesystem_encindex(void);
969
977 VALUE rb_enc_default_external(void);
978
986 VALUE rb_enc_default_internal(void);
987
997void rb_enc_set_default_external(VALUE encoding);
998
1008void rb_enc_set_default_internal(VALUE encoding);
1009
1019 VALUE rb_locale_charmap(VALUE klass);
1020
1021 RBIMPL_SYMBOL_EXPORT_END()
1022
1023
1024#define RB_ENCODING_GET RB_ENCODING_GET
1025#define RB_ENCODING_GET_INLINED RB_ENCODING_GET_INLINED
1026#define RB_ENCODING_IS_ASCII8BIT RB_ENCODING_IS_ASCII8BIT
1027#define RB_ENCODING_SET RB_ENCODING_SET
1028#define RB_ENCODING_SET_INLINED RB_ENCODING_SET_INLINED
1029#define rb_enc_asciicompat rb_enc_asciicompat
1030#define rb_enc_code_to_mbclen rb_enc_code_to_mbclen
1031#define rb_enc_codepoint rb_enc_codepoint
1032#define rb_enc_left_char_head rb_enc_left_char_head
1033#define rb_enc_mbc_to_codepoint rb_enc_mbc_to_codepoint
1034#define rb_enc_mbcput rb_enc_mbcput
1035#define rb_enc_mbmaxlen rb_enc_mbmaxlen
1036#define rb_enc_mbminlen rb_enc_mbminlen
1037#define rb_enc_name rb_enc_name
1038#define rb_enc_prev_char rb_enc_prev_char
1039#define rb_enc_right_char_head rb_enc_right_char_head
1040#define rb_enc_step_back rb_enc_step_back
1041#define rb_enc_str_asciicompat_p rb_enc_str_asciicompat_p
1044#endif /* RUBY_INTERNAL_ENCODING_ENCODING_H */
coderange.h
Routines for code ranges.
ruby_coderange_type
ruby_coderange_type
What rb_enc_str_coderange() returns.
Definition coderange.h:33
RB_ENC_CODERANGE_SET
static void RB_ENC_CODERANGE_SET(VALUE obj, enum ruby_coderange_type cr)
Destructively modifies the passed object so that its (inline) code range is the passed one.
Definition coderange.h:129
const.h
Defines RBIMPL_ATTR_CONST.
RBIMPL_ATTR_CONST
#define RBIMPL_ATTR_CONST()
Wraps (or simulates) __attribute__((const))
Definition const.h:36
deprecated.h
Defines RBIMPL_ATTR_DEPRECATED.
dllexport.h
Tweaking visibility of C variables/functions.
RUBY_EXTERN
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:45
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
fl_type.h
Defines enum ruby_fl_type.
RUBY_FL_USHIFT
@ RUBY_FL_USHIFT
Number of bits in ruby_fl_type that are not open to users.
Definition fl_type.h:159
RB_FL_TEST_RAW
static VALUE RB_FL_TEST_RAW(VALUE obj, VALUE flags)
This is an implementation detail of RB_FL_TEST().
Definition fl_type.h:469
RB_FL_SET_RAW
static void RB_FL_SET_RAW(VALUE obj, VALUE flags)
This is an implementation detail of RB_FL_SET().
Definition fl_type.h:606
RB_FL_UNSET_RAW
static void RB_FL_UNSET_RAW(VALUE obj, VALUE flags)
This is an implementation detail of RB_FL_UNSET().
Definition fl_type.h:666
rb_cEncoding
VALUE rb_cEncoding
Encoding class.
Definition encoding.c:57
rb_enc_dummy_p
int rb_enc_dummy_p(rb_encoding *enc)
Queries if the passed encoding is dummy.
Definition encoding.c:197
rb_enc_get_index
int rb_enc_get_index(VALUE obj)
Queries the index of the encoding of the passed object, if any.
Definition encoding.c:920
rb_to_encoding_index
int rb_to_encoding_index(VALUE obj)
Obtains a encoding index from a wider range of objects (than rb_enc_find_index()).
Definition encoding.c:261
rb_filesystem_encindex
int rb_filesystem_encindex(void)
Identical to rb_filesystem_encoding(), except it returns the encoding's index instead of the encoding...
Definition encoding.c:1529
rb_utf8_encoding
rb_encoding * rb_utf8_encoding(void)
Queries the encoding that represents UTF-8.
Definition encoding.c:1475
RB_ENCODING_SET_INLINED
static void RB_ENCODING_SET_INLINED(VALUE obj, int encindex)
Destructively assigns the passed encoding to the passed object.
Definition encoding.h:81
rb_ascii8bit_encoding
rb_encoding * rb_ascii8bit_encoding(void)
Queries the encoding that represents ASCII-8BIT a.k.a.
Definition encoding.c:1463
RB_ENCODING_IS_ASCII8BIT
static bool RB_ENCODING_IS_ASCII8BIT(VALUE obj)
Queries if the passed object is in ascii 8bit (== binary) encoding.
Definition encoding.h:927
rb_to_encoding
rb_encoding * rb_to_encoding(VALUE obj)
Identical to rb_find_encoding(), except it raises an exception instead of returning NULL.
Definition encoding.c:323
rb_encoding
const OnigEncodingType rb_encoding
The type of encoding.
Definition encoding.h:117
rb_filesystem_encoding
rb_encoding * rb_filesystem_encoding(void)
Queries the "filesystem" encoding.
Definition encoding.c:1537
rb_default_internal_encoding
rb_encoding * rb_default_internal_encoding(void)
Queries the "default internal" encoding.
Definition encoding.c:1676
rb_enc_copy
void rb_enc_copy(VALUE dst, VALUE src)
Destructively copies the encoding of the latter object to that of former one.
Definition encoding.c:1149
rb_enc_left_char_head
static char * rb_enc_left_char_head(const char *s, const char *p, const char *e, rb_encoding *enc)
Queries the left boundary of a character.
Definition encoding.h:683
rb_utf8_encindex
int rb_utf8_encindex(void)
Identical to rb_utf8_encoding(), except it returns the encoding's index instead of the encoding itsel...
Definition encoding.c:1481
rb_enc_fast_mbclen
int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc)
Identical to rb_enc_mbclen() unless the character at p overruns e.
Definition encoding.c:1173
RB_ENCODING_GET
static int RB_ENCODING_GET(VALUE obj)
Just another name of rb_enc_get_index.
Definition encoding.h:195
rb_ascii8bit_encindex
int rb_ascii8bit_encindex(void)
Identical to rb_ascii8bit_encoding(), except it returns the encoding's index instead of the encoding ...
Definition encoding.c:1469
rb_enc_codepoint_len
unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc)
Queries the code point of character pointed by the passed pointer.
Definition encoding.c:1227
rb_enc_unicode_p
int rb_enc_unicode_p(rb_encoding *enc)
Queries if the passed encoding is either one of UTF-8/16/32.
Definition encoding.c:638
rb_enc_to_index
int rb_enc_to_index(rb_encoding *enc)
Queries the index of the encoding.
Definition encoding.c:191
rb_enc_set_index
void rb_enc_set_index(VALUE obj, int encindex)
Destructively assigns an encoding (via its index) to an object.
Definition encoding.c:986
rb_locale_charmap
VALUE rb_locale_charmap(VALUE klass)
Returns a platform-depended "charmap" of the current locale.
Definition localeinit.c:91
rb_enc_set_default_internal
void rb_enc_set_default_internal(VALUE encoding)
Destructively assigns the passed encoding as the default internal encoding.
Definition encoding.c:1726
rb_enc_default_external
VALUE rb_enc_default_external(void)
Identical to rb_default_external_encoding(), except it returns the Ruby-level counterpart instance of...
Definition encoding.c:1603
rb_enc_right_char_head
static char * rb_enc_right_char_head(const char *s, const char *p, const char *e, rb_encoding *enc)
Queries the right boundary of a character.
Definition encoding.h:704
rb_enc_find
rb_encoding * rb_enc_find(const char *name)
Identical to rb_find_encoding(), except it takes a C's string instead of Ruby's.
Definition encoding.c:859
rb_enc_from_encoding
VALUE rb_enc_from_encoding(rb_encoding *enc)
Queries the Ruby-level counterpart instance of rb_cEncoding that corresponds to the passed encoding.
Definition encoding.c:182
rb_find_encoding
rb_encoding * rb_find_encoding(VALUE obj)
Identical to rb_to_encoding_index(), except the return type.
Definition encoding.c:330
rb_define_dummy_encoding
int rb_define_dummy_encoding(const char *name)
Creates a new "dummy" encoding.
Definition encoding.c:566
rb_enc_codepoint
static unsigned int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc)
Queries the code point of character pointed by the passed pointer.
Definition encoding.h:571
rb_default_external_encoding
rb_encoding * rb_default_external_encoding(void)
Queries the "default external" encoding.
Definition encoding.c:1589
rb_locale_encindex
int rb_locale_encindex(void)
Identical to rb_locale_encoding(), except it returns the encoding's index instead of the encoding its...
Definition encoding.c:1501
rb_char_to_option_kcode
int rb_char_to_option_kcode(int c, int *option, int *kcode)
Converts a character option to its encoding.
Definition re.c:333
rb_enc_mbmaxlen
static int rb_enc_mbmaxlen(rb_encoding *enc)
Queries the maximum number of bytes that the passed encoding needs to represent a character.
Definition encoding.h:447
rb_enc_check
rb_encoding * rb_enc_check(VALUE str1, VALUE str2)
Identical to rb_enc_compatible(), except it raises an exception instead of returning NULL.
Definition encoding.c:1062
rb_enc_mbclen
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
Queries the number of bytes of the character at the passed pointer.
Definition encoding.c:1179
RB_ENCODING_SET
static void RB_ENCODING_SET(VALUE obj, int encindex)
Just another name of rb_enc_set_index.
Definition encoding.h:221
rb_enc_capable
int rb_enc_capable(VALUE obj)
Queries if the passed object can have its encoding.
Definition encoding.c:884
RB_ENCODING_CODERANGE_SET
static void RB_ENCODING_CODERANGE_SET(VALUE obj, int encindex, enum ruby_coderange_type cr)
This is RB_ENCODING_SET + RB_ENC_CODERANGE_SET combo.
Definition encoding.h:238
rb_enc_default_internal
VALUE rb_enc_default_internal(void)
Identical to rb_default_internal_encoding(), except it returns the Ruby-level counterpart instance of...
Definition encoding.c:1685
rb_enc_associate_index
VALUE rb_enc_associate_index(VALUE obj, int encindex)
Identical to rb_enc_set_index(), except it additionally does contents fix-up depending on the passed ...
Definition encoding.c:994
rb_enc_compatible
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
Look for the "common" encoding between the two.
Definition encoding.c:1140
RB_ENCODING_GET_INLINED
static int RB_ENCODING_GET_INLINED(VALUE obj)
Queries the encoding of the passed object.
Definition encoding.h:99
rb_locale_encoding
rb_encoding * rb_locale_encoding(void)
Queries the encoding that represents the current locale.
Definition encoding.c:1523
rb_usascii_encoding
rb_encoding * rb_usascii_encoding(void)
Queries the encoding that represents US-ASCII.
Definition encoding.c:1487
rb_enc_set_default_external
void rb_enc_set_default_external(VALUE encoding)
Destructively assigns the passed encoding as the default external encoding.
Definition encoding.c:1643
rb_enc_alias
int rb_enc_alias(const char *alias, const char *orig)
Registers an "alias" name.
Definition encoding.c:670
rb_enc_code_to_mbclen
static int rb_enc_code_to_mbclen(int c, rb_encoding *enc)
Identical to rb_enc_codelen(), except it returns 0 for invalid code points.
Definition encoding.h:619
rb_enc_step_back
static char * rb_enc_step_back(const char *s, const char *p, const char *e, int n, rb_encoding *enc)
Scans the string backwards for n characters.
Definition encoding.h:726
rb_enc_ascget
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
Queries the code point of character pointed by the passed pointer.
Definition encoding.c:1203
rb_enc_str_asciicompat_p
static bool rb_enc_str_asciicompat_p(VALUE str)
Queries if the passed string is in an ASCII-compatible encoding.
Definition encoding.h:789
rb_usascii_encindex
int rb_usascii_encindex(void)
Identical to rb_usascii_encoding(), except it returns the encoding's index instead of the encoding it...
Definition encoding.c:1493
len
int len
Length of the buffer.
Definition io.h:8
noalias.h
Defines RBIMPL_ATTR_NOALIAS.
RBIMPL_ATTR_NOALIAS
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition noalias.h:66
inline
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:91
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition pure.h:33
rbasic.h
Defines struct RBasic.
returns_nonnull.h
Defines RBIMPL_ATTR_RETURNS_NONNULL.
RBIMPL_ATTR_RETURNS_NONNULL
#define RBIMPL_ATTR_RETURNS_NONNULL()
Wraps (or simulates) __attribute__((returns_nonnull))
Definition returns_nonnull.h:34
OnigEncodingTypeST
Definition onigmo.h:160
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40