Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I output FourCharCode variable as text?



At 18:46 +0100 27-11-2003, Camillo Lugaresi wrote:
At 23:41 -0800 26-11-2003, Tom Becker wrote:
Good point, but in MacRoman only the control characters are unprintable, so
a very simple test will at least produce something where you can tell what
it is:

void Print(FourCharCode id)
{
if (id >= 0x20202020)
printf("%.4s", (char*)&id);
else
printf("0x%08x", id);
}

I've actually used code like this before in applications where IDs were a
mixture of alpha codes and numbers.

Using (id >= 0x20202020) for the purpose you stated above is such an incredible conceptual mistake that by merely looking at it I feel my sanity is in danger. I'm serious, I'm going to close this window right away before my mind breaks down.

Clarification: by "the purpose you stated above" I meant the note above the code on control characters in MacRoman, not the part below the code (but above my reply, ack) about mixing alpha codes and numbers in your IDs. Of course, for your own types you can define a boundary above which only sequences of four printable MacRoman characters are considered valid. Then, the function above, which is inapplicable to the general case, could be appropriate.

Of course, that's not the case with most instances of FourCharCodes in Mac applications (ie, for use with OS-defined types), but if your code is only meant to be used on your app's internal types, then it can be sufficient. For a moment, I was thinking you were using (id >= 0x20202020) to check if all bytes were non-control characters, which would have been really unsettling.

Camillo
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: How do I output FourCharCode variable as text? (From: Tom Becker <email@hidden>)
 >Re: How do I output FourCharCode variable as text? (From: Camillo Lugaresi <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.