StringHash
- Parameters
-
s string
- comment
Returns a string hash for the given string. The string is normalized before hashing.
The hash is supposed to be case-insensitive of the input string: this works for ASCII and (Reforged) some small subset of Unicode (Latin Supplement, Cyrillic...). Also the backslash is the same as forward slash:
/
and\
. A probable explanation for this is the usage of file paths, since the game runs on Windows and Mac OS/OSX. StringHash is also used for variable lookup: string name -> integer index.StringHash("\\") == StringHash("/")
StringHash("AB") == StringHash("ab")
- note
Code for the algorithm "SStrHash2" via "1997 Dr Dobbs article".
- note
Breaking: The hashing of multi-byte characters (Unicode) was changed in v1.30.0/1.31.1. It's unknown if hashes of these characters are different in old versions between Windows/Mac OS or depends on OS-default character page settings (non-Unicode programs on Windows).
- pure
- This function is pure. For the same values passed to it, it will always return the same value.
- patch
1.24a
- Source
- common.j
- return type
integer
- Source code
native StringHash takes string s returns integer