如何在 Windows 中获取文件名中带有冒号的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10386344/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get a file in Windows with a colon in the filename?
提问by David
I am getting errors from customers who are uploading files with a colon in the file name, i.e. C:/uploads/test : doc.html
我从上传文件名中带有冒号的文件的客户那里收到错误,即 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.
我假设某些 Unix 或 Linux 系统正在生成文件,但我不确定用户如何使用无效的文件名保存它们。我编写了一段应该在上传时重命名文档的代码。我的问题是我无法测试它,因为我无法在 Windows 上获取文件名中包含冒号的文件。
回答by Hyman
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
我发现了一个与冒号非常相似的字符,“?” 它是一个 unicode 字符,称为修饰符字母冒号。它没有像全角冒号那样的空格,并且与常规冒号几乎完全相同,但该符号有效。您可以从上面复制并粘贴它,也可以使用代码点U+A789
回答by Mike
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.
冒号是 Windows 文件名的无效字符。您将无法在文件名中允许 ':',但您可以解决它。
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
你可以做听起来已经做过的事情;创建一个脚本,用 UNIX 端的有效字符替换这些无效字符。或者,您可以使用文件名字符转换在 Windows 服务器上处理此问题:http: //support.microsoft.com/kb/289627
回答by adraedin
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
.
根据您提供的文件名,您的文件名中的字符可能不是文字冒号:
,它是 Windows 文件名中的保留字符,而是全角冒号:
。它是一个 Unicode 字符,看起来非常像一个冒号,视觉上被无法删除的空格包围。您可以像处理任何 Unicode 字符一样处理它,代码点是U+FF1A
.
回答by aljgom
Other replacements I've found for reserved characters are
我为保留字符找到的其他替换是
” ? ? ? ∕ ? \? ? ?
”?? ? ∕ ? \? ? ?
回答by imoc
You can use the CJK(Chinese/Japan/Korean) one
您可以使用 CJK(Chinese/Japan/Korean) 一个
":"
“:”
which is pretty generic.
这是非常通用的。
回答by Jeff
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.
在下面的示例中,字体大小为 12,但符号除外,它设置为下标、粗体和字体大小为 16。类似冒号的符号的字符代码为 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.
示例:(C?) 符号 – 下标、Calibri、粗体和 16 号字体。
*Using Windows 7, and Word 2007
*使用 Windows 7 和 Word 2007