diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-12-16 13:48:49 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2023-12-16 16:00:12 +0900 |
commit | b710f96b5aaeb6c153e4b1a7e1b46c4521214126 (patch) | |
tree | 482638479eea7df6f5a9602432704628869250c0 | |
parent | dd49ee152ba4153f5c4cf44896975cf1e0ee739e (diff) |
[Bug #20068] Encoding does not matter to empty strings
-rw-r--r-- | string.c | 2 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 1 |
2 files changed, 2 insertions, 1 deletions
@@ -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; } diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 1c7e085630..4d5dea7328 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -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 |