• 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: Converting four char code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting four char code


  • Subject: Re: Converting four char code
  • From: Eric Blairs <email@hidden>
  • Date: Tue, 11 Feb 2003 13:08:03 -0500

On 2/11/03 at 12:18 PM, Michael Tsai <email@hidden> wrote:

>On Monday, February 10, 2003, at 11:21 PM, Eric Blairs wrote:
>
>>I've seen a number of these floating around, but the one I got in
>>some of my code is from Andrew Stone's Cocoa Files:
>>
>> - (NSString *)stringFromCode:(unsigned long)code {
>> unsigned char c[5];
>>
>> c[0] = code >> 24;
>> c[1] = (code >> 16) & 0xff;
>> c[2] = (code >> 8) & 0xff;
>> c[3] = code & 0xff;
>> c[4] = '\0'; // don't forget to terminate the cstring!
>>
>> return [NSString stringWithCString:c];
>> }
>
>Does this work reliably on systems with different default encodings?
>
I haven't gotten to the point of testing with different encoding types. Since my
personal stuff seems to be in a state of constant development instead of hitting
a feature freeze point, I've only been doing basic testing.

>The way I do it is to put the unsigned long in an NSData and then
>convert that to an NSString with NSMacOSRomanStringEncoding.

That's something I could do as well :)

--Eric
_______________________________________________
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: 
 >Re: Converting four char code (From: Michael Tsai <email@hidden>)

  • Prev by Date: Sending emails with attachments
  • Next by Date: help needed with OO concepts when copying
  • Previous by thread: Re: Converting four char code
  • Next by thread: NSFont and memory management
  • Index(es):
    • Date
    • Thread