[Libreoffice-commits] mso-dumper.git: msodumper/docrecord.py
Miklos Vajna
vmiklos at collabora.co.uk
Wed Aug 6 02:37:40 PDT 2014
msodumper/docrecord.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit 771b435fb0941d21c58cafd78d2c90f905ed29f6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Aug 6 11:36:21 2014 +0200
docrecord: avoid UnicodeEncodeError on non-utf8 terminals
As reported by Tor Lillqvist.
diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py
index 6904c5e..bb13b94 100644
--- a/msodumper/docrecord.py
+++ b/msodumper/docrecord.py
@@ -6,6 +6,7 @@
#
import struct
+import locale
import globals
from docdirstream import DOCDirStream
import docsprm
@@ -3070,7 +3071,8 @@ class Xst(DOCDirStream):
def dump(self):
print '<xst type="Xst" offset="%d">' % self.pos
self.printAndSet("cch", self.readuInt16())
- print '<rgtchar value="%s"/>' % globals.encodeName(self.bytes[self.pos:self.pos + 2 * self.cch].decode('utf-16'), lowOnly=True)
+ lowOnly = locale.getdefaultlocale()[1] == "UTF-8"
+ print '<rgtchar value="%s"/>' % globals.encodeName(self.bytes[self.pos:self.pos + 2 * self.cch].decode('utf-16'), lowOnly=lowOnly)
self.pos += 2 * self.cch
print '</xst>'
More information about the Libreoffice-commits
mailing list