mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add rb_encoding_check function
This commit is contained in:
parent
6594623f62
commit
18031f4102
Notes:
git
2021-08-22 10:39:33 +09:00
1 changed files with 12 additions and 10 deletions
22
encoding.c
22
encoding.c
|
@ -1072,12 +1072,9 @@ rb_enc_get(VALUE obj)
|
|||
return rb_enc_from_index(rb_enc_get_index(obj));
|
||||
}
|
||||
|
||||
static rb_encoding* enc_compatible_str(VALUE str1, VALUE str2);
|
||||
|
||||
rb_encoding*
|
||||
rb_enc_check_str(VALUE str1, VALUE str2)
|
||||
static rb_encoding*
|
||||
rb_encoding_check(rb_encoding* enc, VALUE str1, VALUE str2)
|
||||
{
|
||||
rb_encoding *enc = enc_compatible_str(MUST_STRING(str1), MUST_STRING(str2));
|
||||
if (!enc)
|
||||
rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
|
||||
rb_enc_name(rb_enc_get(str1)),
|
||||
|
@ -1085,15 +1082,20 @@ rb_enc_check_str(VALUE str1, VALUE str2)
|
|||
return enc;
|
||||
}
|
||||
|
||||
static rb_encoding* enc_compatible_str(VALUE str1, VALUE str2);
|
||||
|
||||
rb_encoding*
|
||||
rb_enc_check_str(VALUE str1, VALUE str2)
|
||||
{
|
||||
rb_encoding *enc = enc_compatible_str(MUST_STRING(str1), MUST_STRING(str2));
|
||||
return rb_encoding_check(enc, str1, str2);
|
||||
}
|
||||
|
||||
rb_encoding*
|
||||
rb_enc_check(VALUE str1, VALUE str2)
|
||||
{
|
||||
rb_encoding *enc = rb_enc_compatible(str1, str2);
|
||||
if (!enc)
|
||||
rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
|
||||
rb_enc_name(rb_enc_get(str1)),
|
||||
rb_enc_name(rb_enc_get(str2)));
|
||||
return enc;
|
||||
return rb_encoding_check(enc, str1, str2);
|
||||
}
|
||||
|
||||
static rb_encoding*
|
||||
|
|
Loading…
Add table
Reference in a new issue