From 72dfe8c35ed21e3406c6b1722a344bd30de5ad8f Mon Sep 17 00:00:00 2001 From: Daniel Hahn Date: Tue, 16 Apr 2019 15:23:34 +0200 Subject: [PATCH] Set explicit utf-8 encoding Set the encoding on the XML builder explictly to utf-8. While it may be useful to be able to pass an encoding for the XML, UTF-8 will be correct in most cases, and a fixed utf-8 encoding is preferable to setting no encoding at all. --- lib/sepa_king/message.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sepa_king/message.rb b/lib/sepa_king/message.rb index 3b861f5..d5e3457 100644 --- a/lib/sepa_king/message.rb +++ b/lib/sepa_king/message.rb @@ -41,7 +41,7 @@ def to_xml(schema_name=self.known_schemas.first) raise SEPA::Error.new(errors.full_messages.join("\n")) unless valid? raise SEPA::Error.new("Incompatible with schema #{schema_name}!") unless schema_compatible?(schema_name) - builder = Nokogiri::XML::Builder.new do |builder| + builder = Nokogiri::XML::Builder.new(encoding: 'utf-8') do |builder| builder.Document(xml_schema(schema_name)) do builder.__send__(xml_main_tag) do build_group_header(builder)