What characters are forbidden in Windows and Linux directory names?

前端 未结 17 2861
北海茫月
北海茫月 2020-11-22 01:05

I know that / is illegal in Linux, and the following are illegal in Windows (I think) * . \" / \\ [

17条回答
  •  深忆病人
    2020-11-22 01:49

    Difficulties with defining, what's legal and not were already adressed and whitelists were suggested. But Windows supports more-than-8-bit characters. Wikipedia states, that (for example) the

    modifier letter colon [(See 7. below) is] sometimes used in Windows filenames as it is identical to the colon in the Segoe UI font used for filenames. The [inherited ASCII] colon itself is not permitted.

    Therefore, I want to present a much more liberal approach using Unicode characters to replace the "illegal" ones. I found the result in my comparable use-case by far more readable. Look for example into this block. Plus you can even restore the original content from that. Possible choices and research are provided in the following list:

    1. Instead of * (U+002A * ASTERISK), you can use one of the many listed, for example U+2217 ∗ (ASTERISK OPERATOR) or the Full Width Asterisk U+FF0A *
    2. Instead of ., you can use one of these, for example ⋅ U+22C5 dot operator
    3. Instead of ", you can use “ U+201C english leftdoublequotemark (Alternatives see here)
    4. Instead of / (/ SOLIDUS U+002F), you can use ∕ DIVISION SLASH U+2215 (others here)
    5. Instead of \ (\ U+005C Reverse solidus), you can use ⧵ U+29F5 Reverse solidus operator (more)
    6. Instead of [ (U+005B Left square bracket) and ] (U+005D Right square bracket), you can use for example U+FF3B[ FULLWIDTH LEFT SQUARE BRACKET and U+FF3D ]FULLWIDTH RIGHT SQUARE BRACKET (from here, more possibilities here)
    7. Instead of :, you can use U+2236 ∶ RATIO (for mathematical usage) or U+A789 ꞉ MODIFIER LETTER COLON, (see colon (letter), sometimes used in Windows filenames as it is identical to the colon in the Segoe UI font used for filenames. The colon itself is not permitted) (See here)
    8. Instead of ;, you can use U+037E ; GREEK QUESTION MARK (see here)
    9. For |, there are some good substitutes such as: U+0964 । DEVANAGARI DANDA, U+2223 ∣ DIVIDES or U+01C0 ǀ LATIN LETTER DENTAL CLICK (Wikipedia). Also the box drawing characters contain various other options.
    10. Instead of , (, U+002C COMMA), you can use for example ‚ U+201A SINGLE LOW-9 QUOTATION MARK(see here)
    11. For ? (U+003F ? QUESTION MARK), these are good candidates: U+FF1F ? FULLWIDTH QUESTION MARK or U+FE56 ﹖ SMALL QUESTION MARK (from here, two more from Dingbats Block, search for "question")

提交回复
热议问题