Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.

Commit 19071ed

Browse files
committed
UTF8 supported
1 parent 10dcf3a commit 19071ed

12 files changed

+18
-4
lines changed

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/env/bin python
2+
#-*- coding: utf-8 -*-
23

34
from setuptools import setup, find_packages
45

xmind/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
23

34
"""
45
xmind

xmind/core/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class Element(Node):
183183

184184
def __init__(self, node=None):
185185
self._node = node or self._elementConstructor(
186-
self.TAG_NAME.encode("utf8"))
186+
self.TAG_NAME.decode("utf8"))
187187

188188
def _elementConstructor(self, tag_name,
189189
namespaceURI=None,
@@ -237,7 +237,7 @@ def setAttribute(self, attr_name, attr_value=None):
237237
"""
238238
if attr_value is not None:
239239
self._node.setAttribute(attr_name,
240-
str(attr_value).encode("utf8"))
240+
str(attr_value).decode("utf8"))
241241
elif self._node.hasAttribute(attr_name):
242242
self._node.removeAttribute(attr_name)
243243

@@ -286,7 +286,7 @@ def setTextContent(self, data):
286286
self._node.removeChild(node)
287287

288288
text = DOM.Text()
289-
text.data = data.encode("utf8")
289+
text.data = data.decode("utf8")
290290

291291
self._node.appendChild(text)
292292

xmind/core/const.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
3+
24
"""
35
xmind.core.const
46
~~~~~~~~~~~~~~~~

xmind/core/loader.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
23

34
"""
45
xmind.core.loader

xmind/core/mixin.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
23

34
"""
45
xmind.mixin

xmind/core/position.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
23

34
"""
45
xmind.core.position

xmind/core/relationship.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
23

34
"""
45
xmind.core.relationship

xmind/core/saver.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
__author__ = "[email protected] <Woody Ai>"
1414

15+
import codecs
16+
1517
from . import const
1618
from .. import utils
1719

@@ -28,7 +30,7 @@ def __init__(self, workbook):
2830
def _get_content(self):
2931
content_path = utils.join_path(utils.temp_dir(), const.CONTENT_XML)
3032

31-
with open(content_path, "w") as f:
33+
with codecs.open(content_path, "w", encoding="utf-8") as f:
3234
self._workbook.output(f)
3335

3436
return content_path

xmind/core/sheet.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
23

34
"""
45
xmind.core.sheet

xmind/core/title.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
23

34
"""
45
xmind.core.title

xmind/utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env python
2+
#-*- coding: utf-8 -*-
3+
24
"""
35
xmind.utils
46
~~~~~~~~~~~

0 commit comments

Comments
 (0)