A UInt32 (unsigned long) is a location in memory that takes up 4 contiguous bytes of space and is usually aligned to a 2 or 4 byte address boundary. If it contains the value 'abcd', then you will find the bytes 'a', 'b', 'c', and 'd' in the space the UInt32 occupies.
 
Normally, a string "abcd" means a 5 contiguous byte piece of memory that contains 'a', 'b', 'c', 'd', and nul (the value zero). The nul (0) marks the end of the string. A string is not necessarily aligned to any address boundary.
 
To convert a UInt32 of 'abcd' to a string "abcd", either position a nul (0) byte after the end of the UInt32 space and then cast the address of the UInt32 to a (char *), or move the bytes out of the 4 byte UInt32 space into a character buffer and then place a nul (0) byte at the end, whichever is more convenient. There are any number of other ways.
 
Examples:
 
Given a UInt32 x = 'abcd';
 
// example 1
 
    UInt32 y[2];
    y[0] = x;
    y[1] = 0;
    // string is now in (char *)y
 
// example 2
 
    char buffer[5];
    MemMove(buffer,&x,sizeof(x));
    buffer[4] = 0;
    // string is now in buffer
 
It's all just bytes of memory. Experiment with each. As an exercise, try each on both little and big endian devices. Little endian means the least significant byte is stored at the lowest address. Big endian means the most significant byte is stored at the lowest address. X86 is little endian. ARM is usually little endian, but can be either. 68K is big endian.


 
On 4/18/06, Oscar De León <[EMAIL PROTECTED]> wrote:
Hi,
I suggest a couple of ways:

1. If you convert the numeric value to hex format, each pair of characters will be the ascii code of the letter:

ie:
CreatorID = 1633969266 = 61646472H = 'addr' = ASC(61H), ASC(64H), ASC(64H), ASC(72H)

So convert the CreatorID to Hex, take each 2 characters and get the ASCII code of that number.

2. Calculate the (CreartorID modulus 256) wich will give you the ascii value, then right shift 8 bits the number to get the next value repeating the modulus operation 2 more times. In this case the text will be reversed.

3. I think there is an API that converts that UInt32 to String, but I am not a C developer.

Hope it helps

Regards
Oscar

-----Mensaje original-----
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]En nombre de Phil
Enviado el: Martes, 18 de Abril de 2006 22:14
Para: Palm Developer Forum
Asunto: Convert UInt32 creatorID to 4-letter string


Based on APIs from the Data and Resource Manager, the creator ID of an application is a UInt32. How can I convert the UInt32 creator ID into a 4-letter string (like "addr" or "calc"...) and vice versa?

Thanks in advance.
--
For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/



--
For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/



--
yisdersomenimororsisasisdenderisorsis?
Jeff Loucks -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to