diff options
Diffstat (limited to 'spec/ruby/core/string/scrub_spec.rb')
-rw-r--r-- | spec/ruby/core/string/scrub_spec.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/spec/ruby/core/string/scrub_spec.rb b/spec/ruby/core/string/scrub_spec.rb index 4da44a7992..3137399291 100644 --- a/spec/ruby/core/string/scrub_spec.rb +++ b/spec/ruby/core/string/scrub_spec.rb @@ -56,7 +56,9 @@ describe "String#scrub with a custom replacement" do it "replaces invalid byte sequences in frozen strings" do x81 = [0x81].pack('C').force_encoding('utf-8') (-"abc\u3042#{x81}").scrub("*").should == "abc\u3042*" - utf16_str = ("abc".encode('UTF-16LE').bytes + [0x81]).pack('c*').force_encoding('UTF-16LE') + + leading_surrogate = [0x00, 0xD8] + utf16_str = ("abc".encode('UTF-16LE').bytes + leading_surrogate).pack('c*').force_encoding('UTF-16LE') (-(utf16_str)).scrub("*".encode('UTF-16LE')).should == "abc*".encode('UTF-16LE') end |