mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Check if encoding capable object before check if ASCII compatible
This commit is contained in:
parent
d2483393cb
commit
43e8d9a050
Notes:
git
2022-08-20 10:07:01 +09:00
1 changed files with 3 additions and 0 deletions
3
string.c
3
string.c
|
@ -2526,6 +2526,9 @@ void
|
|||
rb_must_asciicompat(VALUE str)
|
||||
{
|
||||
rb_encoding *enc = rb_enc_get(str);
|
||||
if (!enc) {
|
||||
rb_raise(rb_eTypeError, "not encoding capable object");
|
||||
}
|
||||
if (!rb_enc_asciicompat(enc)) {
|
||||
rb_raise(rb_eEncCompatError, "ASCII incompatible encoding: %s", rb_enc_name(enc));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue