function testStringHash takes string description, string text returns nothing
call DisplayTextToPlayer( Player(0), 0, 0, description + ": '" + text + "' is (" + I2S(StringHash(text)) + ")" )
endfunction
function Trig_StringHashTest_Actions takes nothing returns nothing
// User-defined
local string udg_pathFORWARDSLASHto = "path/to"
local string udg_pathBACKSLASHto = "path\\to"
local string udg_case_upper = "CASE"
local string udg_case_lower = "case"
local string udg_empty_string = ""
local string udg_singlequote = "'"
local string udg_doublequote = "\""
local string udg_cyrillic_lower_ya = "я"
local string udg_german_lower_a_umlaut = "ä"
local string udg_chinese_earth = "地球"
// THE NEXT LINE WAS EDITED IN A HEX-EDITOR TO
// PRODUCE A REAL 8-bit ASCII CHARACTER, NOT UNICODE'S UTF-8!
// If you resave the file in a regular editor, it'll surely encode everything
// as UTF-8.
// Here was supposed to be the literal 8-bit \xA9 copyright character
local string ascii_dec_169_copyright = "" // padding.
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_005" )
call testStringHash("lower-case word", udg_case_lower)
call testStringHash("upper-case word", udg_case_upper)
call testStringHash("empty string", udg_empty_string)
call testStringHash("backslash path", udg_pathBACKSLASHto)
call testStringHash("forward-slash path", udg_pathFORWARDSLASHto)
call testStringHash("single-quote", udg_singlequote)
call testStringHash("double-quote", udg_doublequote)
call DisplayTextToPlayer( Player(0), 0, 0, "(Luashine) I saved war3map.j file encoded as UTF-8, Unicode tests:" )
call testStringHash("cyrillic ya, lower-case, utf-8", udg_cyrillic_lower_ya)
call testStringHash("german a umlaut, lower-case, utf-8", udg_german_lower_a_umlaut)
call testStringHash("chinese simpl word earth, utf-8", udg_chinese_earth)
call testStringHash("0xA9 or dec 169 aka copyright-sign via hex editor", ascii_dec_169_copyright)
// Success!
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_006" )
endfunction