Results 1 to 6 of 6
Hi all. I have a web server running on an ubuntu linux system. But as I thought today I just realized I know next to nothing about characters which are ...
- 09-12-2009 #1Just Joined!
- Join Date
- Sep 2009
- Posts
- 3
Legal Folder Names - Many Misconceptions
Hi all. I have a web server running on an ubuntu linux system. But as I thought today I just realized I know next to nothing about characters which are legal in naming directories. Searching didn't help in the sense that I don't even know if there is a difference between the restrictions of folder names on the web and folder names on a local machine.
Basically I am asking:
-What characters are allowed when naming a directory? Punctuation? Standards Symbols? Chinese? These "pictures": ☺ (side question: what are these types of characters referred to as officially)? ™∞§¶¡•£ªº©´†œ¥? etc
-Even if they are allowed, should I not use them? And why?
-Can all of these legal characters be stored in a MySQL database?
-Are different browsers not able to access the folders with certain characters?
-What is the max folder name length?
-Do all of these questions vary for whatever OS you are hosting on?
The reason I ask such a question is that Id like users to be able to create folders on the site based on a string they type in, but I have no idea which characters to restrict.
Thanks! I know this is a lot, sorry.
- 09-12-2009 #2
The safest way to validate for folder names is alpha numeric and _ (underscore) and - (dash)
If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
- 09-12-2009 #3Just Joined!
- Join Date
- Sep 2009
- Posts
- 3
Hi thanks for the response. Why though? I don't understand.
Using ! and Chinese characters, for example, would allow many users (in a system where the folder name corresponds with the user name) to create many more names, perhaps even preferred by them.
So it'd be nice to include them but at the same time I have no idea what are the cons, if any, in doing so.
- 09-13-2009 #4
I think that technically, you are allowed to have all characters in a filename except / and the null character (\0). In practice, however, you don't want to have anything that is A) difficult to type, or B) interpreted by a shell (!#$*\&^).
- 09-14-2009 #5Just Joined!
- Join Date
- Sep 2009
- Posts
- 3
Okay thank you that's exactly what I was after.
- 09-16-2009 #6Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Technically, you can use *anything* that's not / or NULL in a Linux file name, this is coincident with posix as far as I know.
The problem with file names is always the same: possible is not always the same than desirable. Specially when it comes to weird characters that can't be easily typed or when it comes to multibyte characters (accented characters, chinesse and others).
However, this is becoming less of an issue as the time advances, most new systems nowadays will support utf8 by default, which means they can display virtually any file name correctly as long as there's a font with the needed characters installed in your system. Non utf8 system will not display these file names correctly.
A particularly problematic character can be the line feed character. It's a common error from lots of programmers, even experienced ones, to assume that in a list or stream a line feed is a valid separator, and this is not always true. This is why it's important to use nulls as separators or terminators, and not anything else.
PS. Characters that have a meaning for the shell, like ! () {} can be used as long as they are correctly quoted or escaped.Last edited by i92guboj; 09-16-2009 at 06:30 PM.


Reply With Quote