[Libreoffice-commits] mso-dumper.git: msodumper/docrecord.py
Miklos Vajna
vmiklos at collabora.co.uk
Tue Dec 8 03:28:15 PST 2015
msodumper/docrecord.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
New commits:
commit fcdd7ef280270953ef2c0c9512c6efb29125764b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Dec 8 12:27:53 2015 +0100
docrecord: handle fAnsiString == 0 in PBString
diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py
index 9108dca..5f8dc21 100644
--- a/msodumper/docrecord.py
+++ b/msodumper/docrecord.py
@@ -4142,14 +4142,19 @@ class PBString(DOCDirStream):
self.printAndSet("cch", buf & 0x7fff) # bits 0..15
self.printAndSet("fAnsiString", self.getBit(buf, 15))
- # TODO support fAnsiString == 0
bytes = []
- for dummy in range(self.cch):
+ if self.fAnsiString:
+ cch = self.cch
+ else:
+ cch = self.cch * 2
+ for dummy in range(cch):
c = self.readuInt8()
- if c == 0:
- break
bytes.append(c)
- encoding = "ascii"
+
+ if self.fAnsiString == 1:
+ encoding = "ascii"
+ else:
+ encoding = "utf-16"
self.printAndSet("rgxch", globals.encodeName("".join(map(lambda c: chr(c), bytes)).decode(encoding), lowOnly=True).encode('utf-8'), hexdump=False)
print '</%s>' % self.name
More information about the Libreoffice-commits
mailing list