Re: String in hexadecimal
Re: String in hexadecimal
- Subject: Re: String in hexadecimal
- From: Daryn <email@hidden>
- Date: Tue, 27 Jan 2004 10:30:54 -0600
If you are doing this for persistent storage, then just use NSString's
dataUsingEncoding:. NSData's description will give a hex dump of its
contents.
Otherwise, this is probably what you want (untested, but should work):
int len = [string count];
id hexString = [NSMutableString string];
for (i=0;i<len;i++) {
[hexString appendFormat:@" %x",[string characterAtIndex:i]];
if (i && !i%8) [hexString appendString:@"\n"];
}
On Jan 27, 2004, at 1:17 AM, Jacob Chapa wrote:
>
well I think that would give me something like this:
>
>
if my string was "15", it would give me hex for 15.
>
>
I mean I want to get the ASCII value of each of the letters in the
>
string and convert it to hex.
>
>
At least I think thats what you do when u encode a string to hex.
>
>
On Jan 27, 2004, at 1:10 AM, Daryn wrote:
>
>
> Your question is rather vague, but I think this may be what you want:
>
>
>
> [NSString stringWithFormat:@"%x",[myString intValue]]
>
>
>
> On Jan 26, 2004, at 11:50 PM, Jacob Chapa wrote:
>
>
>
>> Anyone know how to get a hexadecimal value of a string?
>
>>
>
>> Thanks
>
>> _______________________________________________
>
>> cocoa-dev mailing list | email@hidden
>
>> Help/Unsubscribe/Archives:
>
>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
>> Do not post admin requests to the list. They will be ignored.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.