Add Encoding::UNICODE_VERSION constant

This commit is contained in:
Nobuyoshi Nakada 2025-04-23 11:22:55 +09:00 committed by Nobuyoshi Nakada
parent 5f3fb35a14
commit b4417ff665
Notes: git 2025-04-23 05:14:50 +00:00
3 changed files with 12 additions and 2 deletions

View File

@ -801,7 +801,6 @@ SpecialsCopy:
return (int )(to - to_start); return (int )(to - to_start);
} }
#if 0
const char onigenc_unicode_version_string[] = const char onigenc_unicode_version_string[] =
#ifdef ONIG_UNICODE_VERSION_STRING #ifdef ONIG_UNICODE_VERSION_STRING
ONIG_UNICODE_VERSION_STRING ONIG_UNICODE_VERSION_STRING
@ -817,4 +816,3 @@ const int onigenc_unicode_version_number[3] = {
0 0
#endif #endif
}; };
#endif

View File

@ -1953,6 +1953,17 @@ Init_Encoding(void)
rb_marshal_define_compat(rb_cEncoding, Qnil, 0, enc_m_loader); rb_marshal_define_compat(rb_cEncoding, Qnil, 0, enc_m_loader);
} }
void
Init_unicode_version(void)
{
extern const char onigenc_unicode_version_string[];
VALUE str = rb_usascii_str_new_static(onigenc_unicode_version_string,
strlen(onigenc_unicode_version_string));
OBJ_FREEZE(str);
rb_define_const(rb_cEncoding, "UNICODE_VERSION", str);
}
void void
Init_encodings(void) Init_encodings(void)
{ {

View File

@ -75,6 +75,7 @@ rb_call_inits(void)
CALL(ast); CALL(ast);
CALL(shape); CALL(shape);
CALL(Prism); CALL(Prism);
CALL(unicode_version);
// enable builtin loading // enable builtin loading
CALL(builtin); CALL(builtin);