/
usr
/
lib
/
python2.6
/
site-packages
/
tablib
/
packages
/
xlwt3
/
/usr/lib/python2.6/site-packages/tablib/packages/xlwt3
mkdir
upload
Name
Size
Mode
Actions
antlr.py
86997
0644
edit
dl
rm
BIFFRecords.py
94877
0644
edit
dl
rm
BIFFRecords.pyc
112961
0644
edit
dl
rm
Bitmap.py
10639
0644
edit
dl
rm
Bitmap.pyc
7737
0644
edit
dl
rm
Cell.py
8367
0644
edit
dl
rm
Cell.pyc
7968
0644
edit
dl
rm
Column.py
1046
0644
edit
dl
rm
Column.pyc
1801
0644
edit
dl
rm
CompoundDoc.py
19548
0644
edit
dl
rm
CompoundDoc.pyc
13816
0644
edit
dl
rm
ExcelFormula.py
1391
0644
edit
dl
rm
ExcelFormula.pyc
2382
0644
edit
dl
rm
ExcelFormulaLexer.py
4311
0644
edit
dl
rm
ExcelFormulaLexer.pyc
4869
0644
edit
dl
rm
ExcelFormulaParser.py
22812
0644
edit
dl
rm
ExcelFormulaParser.pyc
15646
0644
edit
dl
rm
ExcelMagic.py
29668
0644
edit
dl
rm
ExcelMagic.pyc
29698
0644
edit
dl
rm
Formatting.py
8616
0755
edit
dl
rm
Formatting.pyc
8981
0644
edit
dl
rm
Row.py
10111
0644
edit
dl
rm
Row.pyc
10761
0644
edit
dl
rm
Style.py
19705
0644
edit
dl
rm
Style.pyc
16907
0644
edit
dl
rm
UnicodeUtils.py
3408
0644
edit
dl
rm
UnicodeUtils.pyc
3460
0644
edit
dl
rm
Utils.py
6663
0644
edit
dl
rm
Utils.pyc
5507
0644
edit
dl
rm
Workbook.py
21132
0644
edit
dl
rm
Workbook.pyc
26345
0644
edit
dl
rm
Worksheet.py
43958
0644
edit
dl
rm
Worksheet.pyc
49646
0644
edit
dl
rm
__init__.py
266
0644
edit
dl
rm
__init__.pyc
598
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/tablib/packages/xlwt3/UnicodeUtils.py
(3408B)
''' From BIFF8 on, strings are always stored using UTF-16LE text encoding. The character array is a sequence of 16-bit values4. Additionally it is possible to use a compressed format, which omits the high bytes of all characters, if they are all zero. The following tables describe the standard format of the entire string, but in many records the strings differ from this format. This will be mentioned separately. It is possible (but not required) to store Rich-Text formatting information and Asian phonetic information inside a Unicode string. This results in four different ways to store a string. The character array is not zero-terminated. The string consists of the character count (as usual an 8-bit value or a 16-bit value), option flags, the character array and optional formatting information. If the string is empty, sometimes the option flags field will not occur. This is mentioned at the respective place. Offset Size Contents 0 1 or 2 Length of the string (character count, ln) 1 or 2 1 Option flags: Bit Mask Contents 0 01H Character compression (ccompr): 0 = Compressed (8-bit characters) 1 = Uncompressed (16-bit characters) 2 04H Asian phonetic settings (phonetic): 0 = Does not contain Asian phonetic settings 1 = Contains Asian phonetic settings 3 08H Rich-Text settings (richtext): 0 = Does not contain Rich-Text settings 1 = Contains Rich-Text settings [2 or 3] 2 (optional, only if richtext=1) Number of Rich-Text formatting runs (rt) [var.] 4 (optional, only if phonetic=1) Size of Asian phonetic settings block (in bytes, sz) var. ln or 2·ln Character array (8-bit characters or 16-bit characters, dependent on ccompr) [var.] 4·rt (optional, only if richtext=1) List of rt formatting runs [var.] sz (optional, only if phonetic=1) Asian Phonetic Settings Block ''' from struct import pack def upack2(s, encoding='ascii'): # If not unicode, make it so. if isinstance(s, str): us = s else: us = str(s, encoding) # Limit is based on number of content characters # (not on number of bytes in packed result) len_us = len(us) if len_us > 65535: raise Exception('String longer than 65535 characters') try: encs = us.encode('latin1') # Success here means all chars are in U+0000 to U+00FF # inclusive, meaning that we can use "compressed format". flag = 0 except UnicodeEncodeError: encs = us.encode('utf_16_le') flag = 1 return pack('<HB', len_us, flag) + encs def upack1(s, encoding='ascii'): # Same as upack2(), but with a one-byte length field. if isinstance(s, str): us = s else: us = str(s, encoding) len_us = len(us) if len_us > 255: raise Exception('String longer than 255 characters') try: encs = us.encode('latin1') flag = 0 except UnicodeEncodeError: encs = us.encode('utf_16_le') flag = 1 return pack('<BB', len_us, flag) + encs
Save
cmd:
run