diff options
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c index d4fe6ea124..e6b49ef145 100644 --- a/encoding.c +++ b/encoding.c @@ -968,6 +968,21 @@ enc_set_index(VALUE obj, int idx) } void +rb_enc_raw_set(VALUE obj, rb_encoding *enc) +{ + RUBY_ASSERT(enc_capable(obj)); + + int idx = enc ? ENC_TO_ENCINDEX(enc) : 0; + + if (idx < ENCODING_INLINE_MAX) { + ENCODING_SET_INLINED(obj, idx); + return; + } + ENCODING_SET_INLINED(obj, ENCODING_INLINE_MAX); + rb_ivar_set(obj, rb_id_encoding(), INT2NUM(idx)); +} + +void rb_enc_set_index(VALUE obj, int idx) { rb_check_frozen(obj); |