Why shouldn't I use spaces in file names when I can use a code equivalent? [closed]

北城以北 提交于 2020-01-02 04:41:07

问题


I've read all over the place NOT to use spaces in file names intended for use on the Web, e.g. URLs.

I don't understand what's wrong with using "%20" to replace them when referring to the name in my code. It seems more appropriate to use this replacement because I'm then preserving semantic meaning of my file name.

?


回答1:


It's user friendly to have readable URLs.

For example, this page could have been:

http://stackoverflow.com/questions/1093611/why%20shouldnt%20i%20use%20spaces%20in%20file%20names%20when%20i%20can%20use%20a%20code%20equivalent

Not nearly as readable at first glance.




回答2:


first off, it is not that you can't it is that you shouldn't. It is not best practice to have spaces in your file names, it just complicates things, period.

second, it is harder for someone to manually type in the address if they wish.

i.e. "hey go to my site and get my resume at" www.... /my%20resume

just my $0.02




回答3:


It's ugly. Aesthetics do matter for anything a user sees.




回答4:


Another issue, as mentioned in the "Browser security handbook", some browsers do decode such %20 into whitespace, but some not. This lead to different look of the same link in different browsers.




回答5:


They are not very human readable (memorable or typeable) if they show up in URLs and if they are not properly escaped you can have line breaks in things like email.

What's your reason for using them (instead of PascalCase or Blog-Permalink-style) in the first place?




回答6:


I like to make things as simple as possible for user usability and developer code readability. One way to do that is to not use spaces like that.




回答7:


Use something that's more human readable, such as file-name.html or fileName.html. This will be more human readable and easier to work with.




回答8:


You could just create a download page for your users with a list of all the files. If you force the download on the link the user will never have to type the %20



来源:https://stackoverflow.com/questions/1093611/why-shouldnt-i-use-spaces-in-file-names-when-i-can-use-a-code-equivalent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!