Unpacks 1 to 4 byte integers (big endian).
(s, default=0)
| 100 | |
| 101 | # nunpack |
| 102 | def nunpack(s, default=0): |
| 103 | """Unpacks 1 to 4 byte integers (big endian).""" |
| 104 | l = len(s) |
| 105 | if not l: |
| 106 | return default |
| 107 | elif l == 1: |
| 108 | return ord(s) |
| 109 | elif l == 2: |
| 110 | return struct.unpack('>H', s)[0] |
| 111 | elif l == 3: |
| 112 | return struct.unpack('>L', '\x00'+s)[0] |
| 113 | elif l == 4: |
| 114 | return struct.unpack('>L', s)[0] |
| 115 | else: |
| 116 | raise TypeError('invalid length: %d' % l) |
| 117 | |
| 118 | # decode_text |
| 119 | PDFDocEncoding = ''.join( unichr(x) for x in ( |
no test coverage detected
searching dependent graphs…