且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不同系统中的文件名兼容问题

更新时间:2023-11-21 21:01:04

大多数现代系统开始支持文件系统对象名称中的Unicode.但是,这是一个相对较新的成就.好的,让系统用户享受它们.但让我建议您作为开发人员:仅使用英文名称,仅使用英文名称,仅使用ASCII字符库.相信我,做任何其他事情只会带来一些麻烦.有很多长期遗留的旧代码.它们潜入现代系统并破坏了它们.由于纯粹的文化原因,它们通常未经测试:大多数测试工程师都是开发人员的心脏,并且遵循使用基于ASCII的文件名的旧传统,因此仅在对Unicode支持进行了特定测试的情况下,才对其他名称进行测试,换句话说,仍然测试不足.我还建议避免在文件系统对象名称中留空格,以免造成麻烦.

但是,当然,当您在用户可以创建文件的位置测试软件时,请执行相反的操作:使用尽可能宽的字符库对文件名进行测试.

请参阅:
http://en.wikipedia.org/wiki/Ascii [ http://en.wikipedia.org/wiki/Character_repertoire [ http://en.wikipedia.org/wiki/Unicode [ http://unicode.org/ [ ^ ],
http://en.wikipedia.org/wiki/File_system [ http://en.wikipedia.org/wiki/List_of_file_systems [ http://en.wikipedia.org/wiki/English_language [
Most modern systems started to support Unicode in the names of file system object. It is relatively new achievement though. OK, let users of the system enjoy them. But let me advise you as a developer: use only the names in English and only in English, in ASCII character repertoire only. Believe me, doing anything else will only create some hassles. There are a lot of long-leaving obsolete legacy codes. They sneak into modern systems and spoil them. They are often remain untested due to pure cultural reasons: most test engineers are developers at heart and also follow the old tradition of using ASCII-based file names, so other names are tested only when Unicode support is tested specifically, in other words, it remains under-tested. I would also recommend to avoid blank spaces in file system object names, to stay far from troubles.

But of course, when you test your software where your user can create files, do just the opposite: test it with file names using as wide character repertoire as possible.

Please see:
http://en.wikipedia.org/wiki/Ascii[^],
http://en.wikipedia.org/wiki/Character_repertoire[^],
http://en.wikipedia.org/wiki/Unicode[^],
http://unicode.org/[^],
http://en.wikipedia.org/wiki/File_system[^],
http://en.wikipedia.org/wiki/List_of_file_systems[^],
http://en.wikipedia.org/wiki/English_language[^] :-).

—SA


以下链接将很有帮助-

http://social.msdn.microsoft.com/Forums/zh/netfxnetcom/thread/3dd945f7-411a-443d-ac17-fef388272c49 [ http://msdn.microsoft.com/en-us/library/kdcak6ye.aspx [ ^ ]

-Adwait
Following Links will be helpful -

http://social.msdn.microsoft.com/Forums/en/netfxnetcom/thread/3dd945f7-411a-443d-ac17-fef388272c49[^]

http://msdn.microsoft.com/en-us/library/kdcak6ye.aspx[^]

-- Adwait


您为什么认为文件名看起来像是混乱的代码以搜索引擎"?当img标记与中文文件名配合使用时(例如,在html源中正确显示为中文,并且在浏览器中显示使用该标记的页面时显示了图像),那么我看不出原因为什么从搜索引擎的角度来看应该是一些无用的字符.

您还可以为图像的描述添加alt标记-搜索引擎可能会使用该标记.

Google提供了网站主工具",这些工具提供了有关您网站的许多有用信息.我不知道Google的中文网站或其他中文搜索引擎是否也提供此类工具.
Why do you think the filename "looks in messy code to search engines"? When the img tag works fine with the Chinese filename (i.e. in the html source it is shown correctly in Chinese, and the image is displayed when the page using that tag is shown in a browser), then I do not see a reason why it should be some useless characters from the point of view of a search engine.

You could also add an alt tag for the description of your image - search engines might use that.

Google offers "web master tools" which provide a lot of useful information about your web site. I do not know if Google''s Chinese site or other Chinese search engines also offer such tools.