Skip to content

Commit

Permalink
refactor: simplify fix from 2e260f5 / #2434
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Feb 8, 2022
1 parent f6702ba commit b5768c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/nokogiri/xml/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def serialize(*args, &block)
options[:encoding] ||= document.encoding
encoding = Encoding.find(options[:encoding] || "UTF-8")

io = StringIO.new(String.new(encoding: encoding), "wb:#{encoding}:#{encoding}")
io = StringIO.new(String.new(encoding: encoding))

write_to(io, options, &block)
io.string
Expand Down
2 changes: 1 addition & 1 deletion test/xml/test_document_encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TestDocumentEncoding < Nokogiri::TestCase

# the document needs to be large enough to trigger a libxml2 buffer flush. the buffer size
# is determined by MINLEN in xmlIO.c, which is hardcoded to 4000 code points.
size = 4000
size = 8000
input = String.new(<<~XML, encoding: "UTF-16")
<?xml version="1.0" encoding="UTF-16"?>
<root>
Expand Down

0 comments on commit b5768c6

Please sign in to comment.