On Nov 26, 2011, at 4:17 PM, Koen van der Drift wrote:
> I'm pretty sure I messed up something. One of the reasons I posted it here :)
>
> After spitting through the internets, what I am using now is this:
>
> NSData *base64DecodedData = [NSData dataFromBase64String:
> @"Q5YIjESWO5JDlpIbRzMVL0OW="];
>
> for (NSInteger n = 0; n < 4; n++)
> {
> u_int32_t value;
> [base64DecodedData getBytes: &value range: NSMakeRange( n*4,
> sizeof( u_int32_t ) )];
>
> u_int32_t result = CFSwapInt32HostToBig( value );
> NSLog(@"%u", result);
> }
>
> This gives:
>
> 1133906060
> 1150696338
> 1133941275
> 1194530095
>
> This correspond to the values I am getting using the unpack function in a
> Perl script that does what I need, so I think I am on the right track. The
> perl script continues with $float = unpack("f", pack("I", $i));, where $i is
> one of the four numbers above. This gives the expected values for the
> floats. So I may not need the ntohl() function at all.
>
> Now I need to figure out how to go from u_int_32 to float.
I think what you had before would work for the byte swap & conversion, assuming
that your "result" was an array of floats; CFSwapInt32HostToBig is not really
the right call--when it works it is by accident.
--
Scott Ribe
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]