Skip to content

Commit

Permalink
Merge pull request #2447 from sparklemotion/flavorjones-simplify-utf1…
Browse files Browse the repository at this point in the history
…6-fix

refactor: simplify fix from 2e260f5 / #2434
  • Loading branch information
flavorjones committed Feb 9, 2022
2 parents f6702ba + b5768c6 commit a602399
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 a602399

Please sign in to comment.