How to get a file in Windows with a colon in the filename?

久未见 提交于 2019-11-26 03:41:25

问题


I am getting errors from customers who are uploading files with a colon in the file name, i.e. C:/uploads/test : doc.html

I assume that some Unix or Linux system is generating the file but I\'m not sure how the users are saving them with the invalid filename. I have coded a piece that should rename the document on upload. My problem is that I can\'t test it because I can\'t get a file on Windows that has a colon in the filename.


回答1:


I found a very similar character to a colon, "꞉" it is a unicode character called a Modifier Letter Colon. This has no space like the fullwidth colon and is pretty much exactly the same as a regular colon but the symbol works. You can either copy and paste it from above or you can use the code point, U+A789




回答2:


A colon is an invalid character for a Windows file name. You won't be able to allow ':' in the file name, but you can work around it.

You can either do what it sounds like you have already done; create a script that replaces these invalid characters with valid ones on the UNIX side. Or, you can take care of this on the Windows server with File Name Character Translation: http://support.microsoft.com/kb/289627




回答3:


It's probable from the filename you provided that the character you have in your filenames is not a literal colon :, which is a reserved character in Windows filenames, but a fullwidth colon Instead. It's a Unicode character that looks very much like a colon, visually surrounded by spaces that you can't remove. You can handle it the very same way as any Unicode chacter, the code point is U+FF1A.




回答4:


Other replacements I've found for reserved characters are

” ‹ › ⁎ ∕ ⑊ \︖ ꞉ ⏐




回答5:


You can use the CJK(Chinese/Japan/Korean) one

":"

which is pretty generic.




回答6:


HOW TO NAME A FILE OR FOLDER USING A SYMBOL THAT LOOKS LIKE A COLON

In the example below, the font size is 12, with the exception of the symbol, which is set to Subscript, Bold and a font size of 16. The character code for the colon-like symbol is 02F8.

The reason for the Subscript setting is to position the symbol lower relative to its vertical position. The bold and larger font settings are applied so that the symbol is more discernible on the page, and have no affect when used in a file or folder name.

Example: (C˸) Symbol – Subscript, Calibri, Bold and font size of 16.

*Using Windows 7, and Word 2007



来源:https://stackoverflow.com/questions/10386344/how-to-get-a-file-in-windows-with-a-colon-in-the-filename

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