MCPcopy Index your code
hub / github.com/clips/pattern / nunpack

Function nunpack

pattern/web/pdf/utils.py:102–116  ·  view source on GitHub ↗

Unpacks 1 to 4 byte integers (big endian).

(s, default=0)

Source from the content-addressed store, hash-verified

100
101# nunpack
102def 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
119PDFDocEncoding = ''.join( unichr(x) for x in (

Callers 3

get_posMethod · 0.90
do_keywordMethod · 0.90
__init__Method · 0.90

Calls 1

lenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…