Hi
I pushed a fix. It is also attached. Please test.
Bastian
--
Vulcans believe peace should not depend on force.
-- Amanda, "Journey to Babel", stardate 3842.3
commit 298c96cdb311ed847bc4d75df1e89adb239879d5
Author: Bastian Blank <[email protected]>
Date: Tue Mar 25 21:02:16 2014 +0100
Add support for 16-bit strings
diff --git a/dvdvideo/udf/general.py b/dvdvideo/udf/general.py
index 1f819e4..ba6b6c1 100644
--- a/dvdvideo/udf/general.py
+++ b/dvdvideo/udf/general.py
@@ -38,10 +38,10 @@ class OSTACompressedUnicode(str):
stype = buf[0]
if stype == 8:
- return buf[1:].decode()
+ return buf[1:].decode('utf-8')
elif stype == 16:
- raise NotImplementedError
- raise RuntimeError
+ return buf[1:].decode('utf-16be')
+ raise ValueError
class ExtentAD(object):
diff --git a/dvdvideo/udf/test_general.py b/dvdvideo/udf/test_general.py
new file mode 100644
index 0000000..4cee135
--- /dev/null
+++ b/dvdvideo/udf/test_general.py
@@ -0,0 +1,40 @@
+"""
+@copyright: 2014 Bastian Blank <[email protected]>
+@license: GNU GPL-3
+"""
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import pytest
+
+from .general import *
+
+
+class TestOSTACompressedUnicode:
+ def test_stype_8(self):
+ i = b'\x08test'
+ assert OSTACompressedUnicode(i) == 'test'
+
+ def test_stype_16(self):
+ i = b'\x10\00t\00e\00s\00t'
+ assert OSTACompressedUnicode(i) == 'test'
+
+ def test_stype_16_truncated(self):
+ pytest.xfail('Truncated string allowed by OSTA Compressed Unicode')
+ i = b'\x10\00t\00e\00s\00t\00'
+ assert OSTACompressedUnicode(i) == 'test\00'
+
+ def test_stype_invalid(self):
+ i = b'\x01test'
+ with pytest.raises(ValueError):
+ OSTACompressedUnicode(i)
+