php's pack/unpack n

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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