| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On 11/27/03 7:31 AM, Jim Hamilton wrote:I can break that!
Print(0x30004142);
would be rendered as "0".
If it breaks, don't do that!
The FourCharCode type is for four character codes, as you can tell by the
name. This is not a user input type where we need to handle extreme and
nonsensical values. It is a type created by developers for developers. All
we need to do is establish a reasonable convention and follow it. A simple
hack allows using the type to convey numbers up to 538976287 (0x2020201F).
That is a lot of numbers. If that is not enough for your application, use a
different type, such as UInt32 or CFStringRef.
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.
| References: | |
| >Re: How do I output FourCharCode variable as text? (From: Tom Becker <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.