Skip to content

Commit 6c37a57

Browse files
author
Charlie Somerville
committed
add Encoding.compatibility?
1 parent f13af33 commit 6c37a57

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

encoding.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,16 @@ rb_enc_aliases(VALUE klass)
16501650
return aliases[0];
16511651
}
16521652

1653+
static VALUE
1654+
encoding_compatibility_p()
1655+
{
1656+
if (rb_encoding_compat) {
1657+
return Qtrue;
1658+
} else {
1659+
return Qfalse;
1660+
}
1661+
}
1662+
16531663
/*
16541664
* An Encoding instance represents a character encoding usable in Ruby. It is
16551665
* defined as a constant under the Encoding namespace. It has a name and
@@ -1873,6 +1883,7 @@ Init_Encoding(void)
18731883
rb_define_singleton_method(rb_cEncoding, "aliases", rb_enc_aliases, 0);
18741884
rb_define_singleton_method(rb_cEncoding, "find", enc_find, 1);
18751885
rb_define_singleton_method(rb_cEncoding, "compatible?", enc_compatible_p, 2);
1886+
rb_define_singleton_method(rb_cEncoding, "compatibility?", encoding_compatibility_p, 0);
18761887

18771888
rb_define_method(rb_cEncoding, "_dump", enc_dump, -1);
18781889
rb_define_singleton_method(rb_cEncoding, "_load", enc_load, 1);

0 commit comments

Comments
 (0)