Encode str with 'utf-8' before hashing.