diff --git a/lib/happymapper.rb b/lib/happymapper.rb
index 0f5c75eb..754a4114 100644
--- a/lib/happymapper.rb
+++ b/lib/happymapper.rb
@@ -294,6 +294,7 @@ def with_nokogiri_config(&blk)
# to retuning an array of multiple items.
# :xpath information where to start the parsing
# :namespace is the namespace to use for additional information.
+ # :encoding explicitly set the encoding to Nokogiri::XML document
#
def parse(xml, options = {})
# Capture any provided namespaces and merge in any namespaces that have
@@ -309,8 +310,9 @@ def parse(xml, options = {})
unless xml.is_a?(Nokogiri::XML::Document)
# Attempt to parse the xml value with Nokogiri XML as a document
# and select the root element
+ encoding = options[:encoding]
xml = Nokogiri::XML(
- xml, nil, nil,
+ xml, nil, encoding,
Nokogiri::XML::ParseOptions::STRICT,
&nokogiri_config_callback
)
diff --git a/spec/fixtures/address.xml b/spec/fixtures/address.xml
index 1460877f..29077133 100644
--- a/spec/fixtures/address.xml
+++ b/spec/fixtures/address.xml
@@ -6,4 +6,4 @@