冒号/星号作为文件名分隔符? [英] Colon/Asterisk as a filename delimiter?
问题描述
我正在寻找一个使用文件名定界符的字符(我将多个文件名存储在纯文本字符串中). Windows似乎不允许在文件名中使用:
,?
,*
,<
,>
,"
,|
,/
和\
.显然,不能使用\
和/
,因为它们表示路径中的某些内容.有什么理由不应该使用其中任何一个?我只是在想,与/
或\
相似,那些其他不允许使用的字符可能具有特殊含义,我不认为它们不会出现在路径名中.在其他7个字符中,为此目的使用的任何绝对安全或绝对不安全的东西吗?
I'm looking for a character to use a filename delimiter (I'm storing multiple filenames in a plaintext string). Windows seems not to allow :
, ?
, *
, <
, >
, "
, |
, /
and \
in filenames. Obviously, \
and /
can't be used, since they mean something within a path. Is there any reason why any of those others shouldn't be used? I'm just thinking that, similar to /
or \
, those other disallowed characters may have special meaning that I shouldn't assume won't be in path names. Of those other 7 characters, are any definitely safe or definitely unsafe to use for this purpose?
推荐答案
字符:
和"
也在路径中使用.冒号是驱动器单元的定界符,当空格是文件夹或文件名的一部分时,会使用引号.
The characters :
and "
are also used in paths. Colon is the drive unit delimiter, and quotation marks are used when spaces are part of a folder or file name.
字符*
和?
在搜索文件时用作通配符.
The charactes *
and ?
are used as wildcards when searching for files.
字符<
和>
用于将应用程序的输入和输出重定向到文件或从文件重定向.
The characters <
and >
are used for redirecting an application's input and output to and from a file.
字符|
用于将一个应用程序的输出管道传输到另一应用程序的输入.
The character |
is used for piping output from one application into input of another application.
我将选择用于分隔文件名的管道字符.它没有在路径中使用,并且其形状具有自然的分离品质.
I would choose the pipe character for separating file names. It's not used in paths, and its shape has a natural separation quality to it.
另一种选择是在字符串中使用XML.开销很大,有些字符需要编码,但是优点是它可以处理任何字符,而且格式易于解释且定义明确.
An alternative could be to use XML in the string. There is a bit of overhead and some characters need encoding, but the advantage is that it can handle any characters and the format is self explanatory and well defined.
这篇关于冒号/星号作为文件名分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!