diff --git a/README.md b/README.md
index 36b97dd4..6e40ec88 100644
--- a/README.md
+++ b/README.md
@@ -166,6 +166,13 @@ address = Address.parse(ADDRESS_XML_DATA, single: true)
The first one returns an array and we return the first instance, the second
will do that work for us inside of parse.
+#### Encoding
+Encoding can be passed as an option to a `parse` to explicitly set the encoding to an XML.
+
+```ruby
+address = Address.parse(ADDRESS_XML_DATA, single: true, encoding: 'UTF-8')
+```
+
### Multiple Elements Mapping
What if our address XML was a little different, perhaps we allowed multiple
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 @@