Hi,
Just wondering if there is a function to create safe filenames?
If i use peoples nicks to create a file they often have "|" or "\" or "/", I have seen somewhere a function for "safe sql-queries" but is there one for filenames?
I have made my own but I don't think it is... well it's probably not that efficient, and I don't know how to check some characters :S
If someone could point me to an "safe filename" function or help me with this one I would be greatefull!
Code:
public myReplaceFileName(string[33]){
replace_all(string,32,":","_")
replace_all(string,32,"/","_")
replace_all(string,32,"\","_") // this one looks different in the compiler (the _ is blue instead of red... something is wrong?
replace_all(string,32,"?","_")
replace_all(string,32,"<","_")
replace_all(string,32,">","_")
replace_all(string,32,"|","_")
replace_all(string,32,"^"","_") // dont know if this works... want to replace " in the filename.
replace_all(string,32,"'","_")
replace_all(string,32,"`","_")
replace_all(string,32,"´","_")
// replace_all(string,32,"^","_") // dont know how to replace ^
}
I know some of the characters ARE valid in filenames but I don't want them in my filenames thats why they are in the function.