Refactoring of GetGenderEncoding method.