On 7/25/12 8:48 AM, Justin Purdie wrote:
> I'm working on a project where I need to integrate with some older tech.
> 
> I've been given a specification in which I need to build a string following
> this format:
> 
> 
>       0                   1                   2                   3
>       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
>      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>      |0|0|0|0|0| Ver |1|1 1 1 1 1 1 0|            length             |
>      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>      |0 0 0 0 0| C D | PROTEC| BFLAG |          Sender HLD           |
>      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>      |       Recipient HLD           |
>      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>    Length
>    This field indicates the number of bytes of the whole command, header
> 
>    included. The only possible values are equal to 6 bytes or 10 bytes.
> 
> Elsewhere in the docs, the "CD" field (the other fields are irrelevant for
> my question) is mapped to :
> 
>  CD
>    This field specifies the Coding
>       000 : 5 bits (padded baudot)
>       010 : 6 bits (IPARS)
>       100 : 7 bits (ASCII)
>       110 : 8 bits (EBCDIC)
> 
>       xx1 : R.F.U
> 
> 
> My question is, what format/encoding allows that string of 80 characters to
> be 6 or 10 bytes. None of those encodings seem to give me the right byte
> size, everything comes out to be more. Does anyone have any insight on this?
> 
> Any help is appreciated (tuxtoaster I'm looking at you). Thanks in advance.
> 


You might want to look at doing something with pack/unpack.

http://php.net/manual/en/function.pack.php


-- 
thebigdog

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to