Skip to content

Commit

Permalink
[Bug #20068] Encoding does not matter to empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Dec 16, 2023
1 parent dd49ee1 commit b710f96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion string.c
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions test/ruby/test_string.rb
Expand Up @@ -1344,6 +1344,7 @@ def test_hash
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
Expand Down

0 comments on commit b710f96

Please sign in to comment.