I'm not sure we need to encode the basicFileName do we? Wasn't the original reason for doing this to trick browsers into decoding it (when they shouldn't have been) and IE 8 always treated it at ISO-8859-1 so we don't gain anything by doing it, as we can just put everything that's in ISO-8859-1 directly into this value.