- Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcommon.cpp
More file actions
Latest commit
30 lines (22 loc) · 593 Bytes
/
Copy pathcommon.cpp
File metadata and controls
30 lines (22 loc) · 593 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include"common.h"
unsignedinthash_uppercase(constchar *string)
{
unsignedint hash = 0;
char *p = (char *)string;
while (*p != NULL)
{
hash ^= (hash << 5) + (hash >> 2) + ((*p >= 'a' && *p <= 'z') ? *p - 0x20 : *p);
p++;
}
return hash;
}
unsignedinthash_uppercaseW(constwchar_t* wstring)
{
// Shift-Add-XOR hash
unsignedint hash = 0;
char *string = newchar[wcslen(wstring) + 1];
WideCharToMultiByte(CP_ACP, 0, wstring, -1, string, wcslen(wstring) + 1, NULL, NULL);
hash = hash_uppercase(string);
delete[] string;
return hash;
}