• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: String in hexadecimal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >String in hexadecimal (From: Jacob Chapa <email@hidden>)
 >Re: String in hexadecimal (From: Daryn <email@hidden>)

  • Prev by Date: Re: Apple Mail Plugin
  • Next by Date: Re: Custom Bindings clarification
  • Previous by thread: Re: String in hexadecimal
  • Next by thread: Re: String in hexadecimal
  • Index(es):
    • Date
    • Thread