Re: Quick way to convert hex string represented in ASCII to binary?
Re: Quick way to convert hex string represented in ASCII to binary?
- Subject: Re: Quick way to convert hex string represented in ASCII to binary?
- From: Aaron Burghardt <email@hidden>
- Date: Sun, 30 Jul 2006 09:34:16 -0400
It sounds like you have a workable solution, but if you want to
experiment a little for performance reasons, you have a couple other
options.
The openssl included with OS X has base64 encoding/decoding
functions. IIRC, base64 converts every 2 bytes of data to 3 ASCII
characters, so the encoded data would be more compact than hex
strings. Raw email typically uses base64 for attachments, so you can
look there for an idea of what the output looks like, or use openssl
in Terminal to convert test files. Note, to use openssl in you app,
you have to add -lcrypt to the Other Linker Flags build setting. A
quick Google also found this:
http://www.dribin.org/dave/blog/archives/2006/03/12/base64_cocoa/
If you require hex, the family of printf and scanf functions in the C
library may be more efficient. In Terminal, 'man printf' and 'man
scanf' will provide you details.
HTH,
Aaron
On Jul 29, 2006, at 4:40 PM, Ken Tozier wrote:
Well none of this stuff worked so I ended up writing my own
categories, NSData unicharHexStringFromData and NSString
dataFromUnicharHexString that convert and restore NSData into
unicode hex strings. I can send them through HTTP to PHP scripts
without error, save them in a database, call them back and convert
them back to NSData. May not be the most elegant solution but it's
the only thing that worked. Even NSData description messed with
data in a way that was impossible to restore.
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden