Hallo
ich will sicherstellen, daß eine datei korrekt gespeichert wird und habe aus diesem grund folgende funktion gebastelt:
[autoit]Global $String=""
[/autoit][autoit][/autoit][autoit]For $i=1 to 255
[/autoit][autoit][/autoit][autoit]$String&=Chr($i)
[/autoit][autoit][/autoit][autoit]Next
[/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit]MsgBox(0,"erlaubte zeichen",_FileNameEncode($String))
[/autoit][autoit][/autoit][autoit]MsgBox(0,"TestDateiname",_FileNameEncode(" Test/Dateinaäme?Test<Test>.txt"))
[/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit]Func _FileNameEncode($Filename)
[/autoit][autoit][/autoit][autoit]Local Const $ValidChars[256] = _
[/autoit][autoit][/autoit][autoit][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
[/autoit][autoit][/autoit][autoit]0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, _
[/autoit][autoit][/autoit][autoit]0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, _
[/autoit][autoit][/autoit][autoit]0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, _
[/autoit][autoit][/autoit][autoit]0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
[/autoit][autoit][/autoit][autoit]0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
[/autoit][autoit][/autoit][autoit]0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
[/autoit][autoit][/autoit][autoit]0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[/autoit][autoit][/autoit][autoit]Local $sEncoded=""
[/autoit][autoit][/autoit][autoit]For $i = 1 To StringLen($Filename)
[/autoit][autoit][/autoit][autoit]Local $c = StringMid($Filename, $i, 1)
[/autoit][autoit][/autoit][autoit]If Number($ValidChars[Asc($c)]) Then
[/autoit][autoit][/autoit][autoit]$sEncoded &= $c
[/autoit][autoit][/autoit][autoit]Else
[/autoit][autoit][/autoit][autoit]$sEncoded &= StringFormat("_", Asc($c))
[/autoit][autoit][/autoit][autoit]EndIf
[/autoit][autoit][/autoit][autoit]Next
[/autoit][autoit][/autoit][autoit]Return $sEncoded
[/autoit][autoit][/autoit][autoit]EndFunc
[/autoit]aus dem ascii-satz werden nur folgende zeichen zugelassen (alle unerlaubten werden durch "_" ersetzt)
________________________________!__$___()_+,-._0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz_____________________________________________________________________________________________________________________________________
weiß zufällig jemand, welche zeichen erlaubt sind und welche dateinamen ungültig, dann könnte man diese funktion noch erweitern...
momentan lasse ich ja nicht alle gültigen zeichen zu...
und zb.: der dateiname "LPT1" wäre ungültig!?
falls sich damit jemand auskennt, dann bitte ich hiermit um ergänzungen
lgE