It's tough to explain, but I'm in a rather interesting situation. I've started playing with some HTML5, and wanted to build a simple client/server, with the server being in Pascal. Long story short, a special handshake needs to take place and I'm having trouble writing the code for it.

What I've been searching for, more or less, is a function or set of functions similar to the php function http://php.net/manual/en/function.pack.php

(where I would be using option 'N' like so):
Code:
echo pack('N', 259970620);
and the output is "~?ñ<"

I'm just not sure what do do... I can't seem to find any reference to converting an integer to actual binary (or maybe I'd want bytes in this case?) and then to a string. At the moment I've mostly been nabbing random functions from around the net, but they all return the binary as a string ("10010101"), not the (I guess) ansi representation of the binary, and all 3 functions produce a different result for the same integer, and then there's the matter of the last step again.

Rant:
I feel sorry for any others out here who try to play with websockets. The handshake is just utter nonsense that some fool made up for no reason. Look it up on wikipedia, it's hilarious. You're given two key strings. You remove all characters that are not 0-9. You count the number of spaces. You divide the concat'd numbers (after removing non-numbers and spaces) by the number of spaces, now do the same for the second key. Now convert these to some sort of binary string (independently of each other), concat them, then concat that with some 8 byte nonsense also given to you, then md5 it, then send it back.

^ and the initial connection is an HTTP GET, with which after you complete the handshake it pretends it's a normal TCP connection.