Handle resources with "%" and other special characters in file name more accurately (fixes #401)