Skip to content

Commit

Permalink
String concatenation uses self's encoding if both are ASCII-only
Browse files Browse the repository at this point in the history
  • Loading branch information
herwinw committed Nov 12, 2024
1 parent ddfa26c commit 79c89a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions spec/core/string/shared/concat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@

describe "when self and the argument are in different ASCII-compatible encodings" do
it "uses self's encoding if both are ASCII-only" do
NATFIXME "it uses self's encoding if both are ASCII-only", exception: SpecFailedException do
"abc".encode("UTF-8").send(@method, "123".encode("SHIFT_JIS")).encoding.should == Encoding::UTF_8
end
"abc".encode("UTF-8").send(@method, "123".encode("SHIFT_JIS")).encoding.should == Encoding::UTF_8
end

it "uses self's encoding if the argument is ASCII-only" do
Expand Down
2 changes: 1 addition & 1 deletion src/string_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3481,7 +3481,7 @@ EncodingObject *StringObject::negotiate_compatible_encoding(const StringObject *
if (m_encoding->num() == Encoding::ASCII_8BIT)
return m_encoding.ptr();

if (this_is_ascii)
else if (this_is_ascii && !other_is_ascii)
return other_string->m_encoding.ptr();
else
return m_encoding.ptr();
Expand Down

0 comments on commit 79c89a1

Please sign in to comment.