diff --git a/mappyfile.pyproj b/mappyfile.pyproj
index aab131a..2d8a698 100644
--- a/mappyfile.pyproj
+++ b/mappyfile.pyproj
@@ -10,7 +10,7 @@
.
mappyfile
mappyfile
- MSBuild|mappyfile|$(MSBuildProjectFullPath)
+ MSBuild|mappyfile3|$(MSBuildProjectFullPath)
tests\test_comments.py
@@ -271,6 +271,7 @@
Code
+
diff --git a/mappyfile/parser.py b/mappyfile/parser.py
index cab8ed8..1dae982 100644
--- a/mappyfile/parser.py
+++ b/mappyfile/parser.py
@@ -186,7 +186,7 @@ def parse(self, text, fn=None):
Parse the Mapfile
"""
- text = str(text)
+ text = str(text) # ensure the input is a unicode string
if self.expand_includes:
text = self.load_includes(text, fn=fn)
diff --git a/mappyfile/utils.py b/mappyfile/utils.py
index 5db6cfb..df3e03e 100644
--- a/mappyfile/utils.py
+++ b/mappyfile/utils.py
@@ -83,7 +83,7 @@ def load(fp, expand_includes=True, include_position=False, include_comments=Fals
----------
fp: file
- A file-like object
+ A file-like object - as with all Mapfiles this should be encoded in "utf-8"
expand_includes: boolean
Load any ``INCLUDE`` files in the MapFile
include_comments: boolean
diff --git a/tests/samples/unicode.map b/tests/samples/unicode.map
new file mode 100644
index 0000000..61a8304
--- /dev/null
+++ b/tests/samples/unicode.map
@@ -0,0 +1,23 @@
+ CLASS
+
+ NAME 'Enw’r stryd ddynodedig'
+
+ EXPRESSION /^Designated street.*$/
+
+ STYLE
+
+ #SYMBOL 'line'
+
+ COLOR 255 0 0#red
+
+ OPACITY 100
+
+ OUTLINECOLOR 255 0 0
+
+ WIDTH 2
+
+ END
+
+
+
+ END
diff --git a/tests/test_sample_maps.py b/tests/test_sample_maps.py
index 9b2765e..841777d 100644
--- a/tests/test_sample_maps.py
+++ b/tests/test_sample_maps.py
@@ -114,6 +114,14 @@ def test_non_ascii():
print(mappyfile.dumps(d))
+def test_unicode_map():
+
+ with open('./tests/samples/unicode.map', "r", encoding="utf-8") as mf_file:
+ mf = mappyfile.load(mf_file)
+
+ print(mappyfile.dumps(mf))
+
+
def run_tests():
pytest.main(["tests/test_sample_maps.py"])
@@ -121,6 +129,6 @@ def run_tests():
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('mappyfile').setLevel(logging.INFO)
- run_tests()
- # test_includes()
+ # run_tests()
+ test_unicode_map()
print("Done!")