This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
characters_filenames [2019-09-21 19:31:04] mi created |
characters_filenames [2020-06-20 23:14:40] (current) mi [Path separators] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Characters in file names ====== | ====== Characters in file names ====== | ||
| + | |||
| + | Note : this page often uses "Unix" for non-Windows systems, because Mac OS and Linux are both Unix-based systems. And the Web standard also originated on Unix systems, so for example, it's path separator is the same "/". | ||
| + | |||
| + | ===== Path separators ===== | ||
| + | * / in Unix and on the web. Windows also accpts it in some contexts, but sometimes not. | ||
| + | * \ in Windows. But it's an escape character in Unix. | ||
| + | * : was used in the old Mac OS up to version 9. See the [[#Mac : / confusion]] below. | ||
| + | |||
| + | ===== Escape characters ===== | ||
| + | |||
| + | * \ Unix escape | ||
| + | * ^ Windows cmd.exe escape | ||
| + | * ` Windows PowerShell escape | ||
| + | |||
| + | (see also https://en.wikipedia.org/wiki/Escape_character) | ||
| ===== Windows Powershell ===== | ===== Windows Powershell ===== | ||
| The Windows Powershell (v. 2 in Win7) has a function `GetInvalidFileNameChars()` : | The Windows Powershell (v. 2 in Win7) has a function `GetInvalidFileNameChars()` : | ||
| - | <code>ForEach ($c in [System.IO.Path]::GetInvalidFileNameChars()) { $i=([int]$c); "{0,3:d} {1,2:x2} {2,1}" -f $i,$i,$c } | + | <code> |
| - | 34 22 " | + | [System.IO.Path]::GetInvalidFileNameChars() | ForEach-Object {$i=[int]$_; '{0,3} {1:X2} {2}' -f $i,$i,$_ } | Sort-Object |
| - | 60 3c < | + | 0 00 |
| - | 62 3e > | + | 1 01 ☺ |
| - | 124 7c | | + | 2 02 ☻ |
| - | 0 00 | + | 3 03 ♥ |
| - | 1 01 ☺ | + | 4 04 ♦ |
| - | 2 02 ☻ | + | 5 05 ♣ |
| - | 3 03 ♥ | + | 6 06 ♠ |
| - | 4 04 ♦ | + | 7 07 |
| - | 5 05 ♣ | + | 8 08 |
| - | 6 06 ♠ | + | 9 09 |
| - | 7 07 | + | 10 0A |
| - | 8 08 | + | |
| - | 9 09 | + | |
| - | 10 0a | + | |
| - | 11 0b ♂ | + | 11 0B ♂ |
| - | 12 0c ♀ | + | 12 0C ♀ |
| - | 13 0d | + | 13 0D |
| - | 14 0e ♫ | + | 14 0E ♫ |
| - | 15 0f ☼ | + | 15 0F ☼ |
| - | 16 10 ► | + | 16 10 ► |
| - | 17 11 ◄ | + | 17 11 ◄ |
| - | 18 12 ↕ | + | 18 12 ↕ |
| - | 19 13 ‼ | + | 19 13 ‼ |
| - | 20 14 ¶ | + | 20 14 ¶ |
| - | 21 15 § | + | 21 15 § |
| - | 22 16 ▬ | + | 22 16 ▬ |
| - | 23 17 ↨ | + | 23 17 ↨ |
| - | 24 18 ↑ | + | 24 18 ↑ |
| - | 25 19 ↓ | + | 25 19 ↓ |
| - | 26 1a → | + | 26 1A → |
| - | 27 1b ← | + | 27 1B ← |
| - | 28 1c ∟ | + | 28 1C ∟ |
| - | 29 1d ↔ | + | 29 1D ↔ |
| - | 30 1e ▲ | + | 30 1E ▲ |
| - | 31 1f ▼ | + | 31 1F ▼ |
| - | 58 3a : | + | 34 22 " |
| - | 42 2a * | + | 42 2A * |
| - | 63 3f ? | + | 47 2F / |
| - | 92 5c \ | + | 58 3A : |
| - | 47 2f / | + | 60 3C < |
| + | 62 3E > | ||
| + | 63 3F ? | ||
| + | 92 5C \ | ||
| + | 124 7C | | ||
| </code> | </code> | ||
| + | |||
| + | So it lists the obvious control characters 0 to 31 (x00-x1F), plus | ||
| + | * " | ||
| + | * * | ||
| + | * / | ||
| + | * : | ||
| + | * < | ||
| + | * > | ||
| + | * ? | ||
| + | * \ | ||
| + | * | | ||
| + | |||
| + | ===== At start or end of file name ===== | ||
| + | * space at the end of a file or directory name is ignored/removed by Windows. It is OK in Unix, but obviously a problem because it's invisible. | ||
| + | * . dot at the end of a file or directory name is ignored/removed by Windows. | ||
| + | * . dot at the start of a file or directory name makes it "hidden" in Unix. It will not show in normal directory listings and file managers. | ||
| + | |||
| + | ===== Mac : / confusion ===== | ||
| + | Mac OS in the eighties and nineties (up to version 9) was not a Unix-based system, and used ":" as a path separator. "/" had no special meaning for Macs, so it was accepted in file names like "report 25/3/1992". | ||
| + | |||
| + | When Mac replaced it's OS with Unix, "/" became an invalid character in file names, but on the other hand, ":" was now a perfectly normal character. So it decided to silently replace all "/" with ":", and made it's graphical interface handle the translation invisibly. So you can still see this "report 25/3/1992" file in the Finder, and you can have the impression that you can still write a file named "report 25/12/2019". However, the real file name in the file system will be "report 25:3:1992", and some Mac programs will only see the real file name and not "translate" it on the fly. | ||