από medigeek » 03 Φεβ 2012, 03:49
unicode(var, 'utf-8')
Ούτε unicode laterals θέλει ούτε τίποτα, τουλάχιστον για python 2.6/2.7 που δοκίμασα. Πιθανότατα να χρειάζεται σε συνδυασμό με Qt4

python2.7:
- Κώδικας: Επιλογή όλων
>>> a = """Version 6 configuration; created by EncFS 1.7.4 (revision 20100713)
... Filesystem cipher: "ssl/aes", version 3:0:0 (χρήση 3:0:2)
... Filename encoding: "nameio/block", version 3:0:0 (χρήση 3:0:1)
... Μέγεθος κλειδιού: 192 ψηφία
... Using PBKDF2, with 113303 iterations
... Salt Size: 160 bits
... Μέγεθος block: 1024 bytes
... Each file contains 8 byte header with unique IV data.
... Filenames encoded using IV chaining mode.
... File holes passed through to ciphertext."""
>>> a
'Version 6 configuration; created by EncFS 1.7.4 (revision 20100713)\nFilesystem cipher: "ssl/aes", version 3:0:0 (\xcf\x87\xcf\x81\xce\xae\xcf\x83\xce\xb7 3:0:2)\nFilename encoding: "nameio/block", version 3:0:0 (\xcf\x87\xcf\x81\xce\xae\xcf\x83\xce\xb7 3:0:1)\n\xce\x9c\xce\xad\xce\xb3\xce\xb5\xce\xb8\xce\xbf\xcf\x82 \xce\xba\xce\xbb\xce\xb5\xce\xb9\xce\xb4\xce\xb9\xce\xbf\xcf\x8d: 192 \xcf\x88\xce\xb7\xcf\x86\xce\xaf\xce\xb1\nUsing PBKDF2, with 113303 iterations\nSalt Size: 160 bits\n\xce\x9c\xce\xad\xce\xb3\xce\xb5\xce\xb8\xce\xbf\xcf\x82 block: 1024 bytes\nEach file contains 8 byte header with unique IV data.\nFilenames encoded using IV chaining mode.\nFile holes passed through to ciphertext.'
>>> type(a)
<type 'str'>
>>> unicode(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 113: ordinal not in range(128)
>>> unicode(a, 'utf-8')
u'Version 6 configuration; created by EncFS 1.7.4 (revision 20100713)\nFilesystem cipher: "ssl/aes", version 3:0:0 (\u03c7\u03c1\u03ae\u03c3\u03b7 3:0:2)\nFilename encoding: "nameio/block", version 3:0:0 (\u03c7\u03c1\u03ae\u03c3\u03b7 3:0:1)\n\u039c\u03ad\u03b3\u03b5\u03b8\u03bf\u03c2 \u03ba\u03bb\u03b5\u03b9\u03b4\u03b9\u03bf\u03cd: 192 \u03c8\u03b7\u03c6\u03af\u03b1\nUsing PBKDF2, with 113303 iterations\nSalt Size: 160 bits\n\u039c\u03ad\u03b3\u03b5\u03b8\u03bf\u03c2 block: 1024 bytes\nEach file contains 8 byte header with unique IV data.\nFilenames encoded using IV chaining mode.\nFile holes passed through to ciphertext.'
python2.6:
- Κώδικας: Επιλογή όλων
>>> a
'Version 6 configuration; created by EncFS 1.7.4 (revision 20100713)\n... Filesystem cipher: "ssl/aes", version 3:0:0 (\xcf\x87\xcf\x81\xce\xae\xcf\x83\xce\xb7 3:0:2)\n... Filename encoding: "nameio/block", version 3:0:0 (\xcf\x87\xcf\x81\xce\xae\xcf\x83\xce\xb7 3:0:1)\n... \xce\x9c\xce\xad\xce\xb3\xce\xb5\xce\xb8\xce\xbf\xcf\x82 \xce\xba\xce\xbb\xce\xb5\xce\xb9\xce\xb4\xce\xb9\xce\xbf\xcf\x8d: 192 \xcf\x88\xce\xb7\xcf\x86\xce\xaf\xce\xb1\n... Using PBKDF2, with 113303 iterations\n... Salt Size: 160 bits\n... \xce\x9c\xce\xad\xce\xb3\xce\xb5\xce\xb8\xce\xbf\xcf\x82 block: 1024 bytes\n... Each file contains 8 byte header with unique IV data.\n... Filenames encoded using IV chaining mode.\n... File holes passed through to ciphertext.'
>>> type(a)
<type 'str'>
>>> a = """Version 6 configuration; created by EncFS 1.7.4 (revision 20100713)
... Filesystem cipher: "ssl/aes", version 3:0:0 (χρήση 3:0:2)
... Filename encoding: "nameio/block", version 3:0:0 (χρήση 3:0:1)
... Μέγεθος κλειδιού: 192 ψηφία
... Using PBKDF2, with 113303 iterations
... Salt Size: 160 bits
... Μέγεθος block: 1024 bytes
... Each file contains 8 byte header with unique IV data.
... Filenames encoded using IV chaining mode.
... File holes passed through to ciphertext."""
>>> type(a)
<type 'str'>
>>> unicode(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 113: ordinal not in range(128)
>>> unicode(a, "utf-8")
u'Version 6 configuration; created by EncFS 1.7.4 (revision 20100713)\nFilesystem cipher: "ssl/aes", version 3:0:0 (\u03c7\u03c1\u03ae\u03c3\u03b7 3:0:2)\nFilename encoding: "nameio/block", version 3:0:0 (\u03c7\u03c1\u03ae\u03c3\u03b7 3:0:1)\n\u039c\u03ad\u03b3\u03b5\u03b8\u03bf\u03c2 \u03ba\u03bb\u03b5\u03b9\u03b4\u03b9\u03bf\u03cd: 192 \u03c8\u03b7\u03c6\u03af\u03b1\nUsing PBKDF2, with 113303 iterations\nSalt Size: 160 bits\n\u039c\u03ad\u03b3\u03b5\u03b8\u03bf\u03c2 block: 1024 bytes\nEach file contains 8 byte header with unique IV data.\nFilenames encoded using IV chaining mode.\nFile holes passed through to ciphertext.'
Edit:
Μήπως το unicode_laterals δημιουργεί προβλήματα με utf-8 output (αυτό που εμφανίζει το encfs από τερματικό);
http://stackoverflow.com/questions/8097 ... python-2-6