Re: Binary to ASCII

From: Date: Tue, 11 May 2004 00:06:36 +0000
Subject: Re: Binary to ASCII
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-185874@lists.php.net to get a copy of this message
* Thus wrote Curt Zirzow (php-general@zirzow.dyndns.org): > * Thus wrote Ren Fournier (m5@renefournier.com): > > //I would Assume that that was packed with something like this: > $string = 'The system is up and running.'; > $pck = pack('a3iia*a3', 'STX', strlen($string), 38, $string, > 'ENX'); > echo $pck, "\n"; IIRC, your Original post mention the requirement of big endian byte order. If that is the case you want pack('a2NNa*a3', ...) > > //So This will unpack it for you. > $unpacked = unpack('a3code/istrlen/itype/a*stringWithEndDelim', $pck); ditto with unpack: unpack('a3code/Nstrlen/Ntype/a*stringWithEndDelim', ...) See the chart here for what type gets converted from what: http://php.net/pack Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#185874) next »