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.
我不明白在我的代码中引用名称时使用“%20”替换它们有什么问题。使用此替换似乎更合适,因为我保留了我的文件名的语义含义。
?
8 个解决方案
#1
It's user friendly to have readable URLs.
拥有可读的URL对用户友好。
For example, this page could have been:
例如,此页面可能是:
http://*.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
即“嘿,去我的网站,获取我的简历”www .... / my%20resume
just my $0.02
只需我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.
另一个问题,如“浏览器安全手册”中提到的,一些浏览器会将这样的%20解码为空白,但有些则没有。这导致不同浏览器中相同链接的不同外观。
#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.
如果它们出现在URL中,并且如果它们没有被正确转义,则可以在电子邮件等内容中使用换行符,它们不具有人类可读性(令人难忘或可输入)。
What's your reason for using them (instead of PascalCase or Blog-Permalink-style) in the first place?
你首先使用它们(而不是PascalCase或Blog-Permalink风格)的原因是什么?
#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.
使用更易于阅读的内容,例如file-name.html或fileName.html。这将更具人性化,更易于使用。
#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
您可以为用户创建一个下载页面,其中包含所有文件的列表。如果您强制下载链接,用户将永远不必键入%20
#1
It's user friendly to have readable URLs.
拥有可读的URL对用户友好。
For example, this page could have been:
例如,此页面可能是:
http://*.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
即“嘿,去我的网站,获取我的简历”www .... / my%20resume
just my $0.02
只需我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.
另一个问题,如“浏览器安全手册”中提到的,一些浏览器会将这样的%20解码为空白,但有些则没有。这导致不同浏览器中相同链接的不同外观。
#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.
如果它们出现在URL中,并且如果它们没有被正确转义,则可以在电子邮件等内容中使用换行符,它们不具有人类可读性(令人难忘或可输入)。
What's your reason for using them (instead of PascalCase or Blog-Permalink-style) in the first place?
你首先使用它们(而不是PascalCase或Blog-Permalink风格)的原因是什么?
#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.
使用更易于阅读的内容,例如file-name.html或fileName.html。这将更具人性化,更易于使用。
#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
您可以为用户创建一个下载页面,其中包含所有文件的列表。如果您强制下载链接,用户将永远不必键入%20