Use # character in url inside file name

I need to set a link with this href="file://attachments/aaaa_#_aaaa.msg" Obviously, this does not work, because the hash symbol # used for anchors.

So I'm trying to change this to: href="file://attachments/aaaa_%23_aaaa.msg" but when I open the URL in IE, the browser tries to open this: href="file://attachments/aaaa_%2523_aaaa.msg" IE encodes character % to %25

How can I put the file name in the URL to encode and read the hash symbol # in all browsers to download the file?

I cannot change the file name to remove this character, so I need a way to deal with this problem.

+6
source share
1 answer

You can avoid big and big crashes if you can rename your files so that they do not contain the "#" symbol. As long as they do this, you will probably have problems with the current and future cross-browser, confusion on behalf of future developers working on your code (or confusion on your behalf in the future when you forgot all the ins and outs encodings) etc. In addition, some Unix / Linux systems do not allow "#" in file names. You do not know which OS you are using, but your file names should be as portable as possible in different OSs, even if you are "sure" right now that you will never work on one of these systems.

0
source

All Articles