php's pack/unpack n

BlitzMax Forums/BlitzMax Programming/php's pack/unpack n

kronholm(Posted 2008) [#1]
I want to emulate the function of php's pack('n'), which packs to unsigned short (always 16 bit, big endian byte order) and unpack which does the reverse.

But I suck at numbers, and I can't seem to figure it out, been at it for hours now. Anyone got some tips?

Here's a couple examples of what pack does:
11 becomes 12593
ff becomes 26214
 becomes 6161
ÿÿ becomes 65535