Resource hashes and get getNamedResource

I have a resource, created from file “Source Code Pro.bin” with spaces, i imported it into Introjucer and it appears in the switch()/case list like so:

        case 0x2daa4cbe:
        case 0x32c2704e:  numBytes = 28981; return Source_Code_Pro_bin;

Now i try to fetch it using the getNamedResourceMethod, i tried 4 calls each giving a different hash (i entered a debug statement in the getNamedResource function):

const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw()
{
	const char *ptr = resourceNameUTF8;
    unsigned int hash = 0;
    if (resourceNameUTF8 != 0)
        while (*resourceNameUTF8 != 0)
            hash = 31 * hash + *resourceNameUTF8++;

	_DBG ("name="+String(ptr)+" hash="+String::formatted ("0x%x", hash));

    switch (hash)
    {
    ...
}

int size;
getNamedResource("Source Code Pro.bin", size);
getNamedResource("Source Code Pro, size");
getNamedResource("Source_Code_Pro_bin", size);
getNamedResource("Source_Code_Pro", size);

the output is:

(31751979.6) name=Source Code Pro.bin hash=0xb1fc66d8
(31751980.5) name=Source Code Pro, size hash=0x1d76d874
(31751981.1) name=Source_Code_Pro_bin hash=0xf4bb51a7
(31751981.8) name=Source_Code_Pro hash=0x4b3e2cdf

None of them matches the hash generated by Introjucer, how can i match with what Introjucer has generated ?

1 Like

Are you using the latest version?

Damn i had a shortcut on my desktop to a Visual2010/Relase/Introjucer.exe and i was building the one in Viusual2005 so i was testing the rwong build.
The latest source seems to work fine. Sorry for that.