[Bug #20068] Encoding does not matter to empty strings

This commit is contained in:
Nobuyoshi Nakada 2023-12-16 13:48:49 +09:00
parent dd49ee152b
commit b710f96b5a
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
2 changed files with 2 additions and 1 deletions

View File

@ -3586,7 +3586,7 @@ rb_str_prepend_multi(int argc, VALUE *argv, VALUE str)
st_index_t
rb_str_hash(VALUE str)
{
int e = ENCODING_GET(str);
int e = RSTRING_LEN(str) ? ENCODING_GET(str) : 0;
if (e && is_ascii_string(str)) {
e = 0;
}

View File

@ -1344,6 +1344,7 @@ CODE
assert_not_equal(S("a").hash, S("a\0").hash, bug4104)
bug9172 = '[ruby-core:58658] [Bug #9172]'
assert_not_equal(S("sub-setter").hash, S("discover").hash, bug9172)
assert_equal(S("").hash, S("".encode(Encoding::UTF_32BE)).hash)
end
def test_hex