Hardened input checking to handle unicode key names.