rejetto forum
Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Mars on May 16, 2009, 02:16:39 PM
-
I had to create a variable %item-md5% to work on files MD5, but I met some concerns of replacement: nothing crossed it.
As a result, I modified the procedure handleSymbols() by adding her one or two rules more
1) It is possible to use numeric symbols in the names as %var5max21%
2) the name must begin by an only one '_' or by letters 'a'..'z' and 'A'..'Z'
With the compulsory rule that the first char '_' must be followed necessarily by a letter
are accepted %symbol1% , %_symbol2% , %folder% but ar forbidden %5mars% or %_45_test%
procedure handleSymbols();
var
b, e, l : integer;
s, newS: string;
begin
e:=0;
l:=length(txt);
while e < l do
begin
// search for next symbol
b:=posEx('%',txt,e+1);
if b = 0 then break;
e:=b+1;
if txt[e]='_' then inc(e); //first char can be a '_' but necessary with a letter after
if not (txt[e] in ['a'..'z','A'..'Z']) then continue; // assume that the first char is a letter
while (e < l) and (txt[e] in ['0'..'9','a'..'z','A'..'Z','-','_']) do //accept numeric char
inc(e);
if txt[e] <> '%' then continue;
-
ok, but i think it's unnecessary to allow only 1 '_' as first character.
who cares?
i changed this
if txt[e]='_' then inc(e); //first char can be a '_' but necessary with a letter after
if not (txt[e] in ['a'..'z','A'..'Z']) then continue; // assume that the first char is a
into this
if not (txt[e] in ['_','a'..'z','A'..'Z']) then continue; // first valid character
-
with your change: '_---------' or '________' are valid symbols ;D
Identificateurs:
Les identificateurs désignent les constantes, variables, champs, types, propriétés, procédures, fonctions, programmes, unités, bibliothèques et packages. La longueur d'un identificateur peut être quelconque, mais seuls les 255 premiers caractères sont significatifs. Un identificateur doit commencer par un caractère alphabétique ou un souligné (_) et ne peut contenir d'espaces ; après le premier caractère, les caractères alphabétiques, les chiffres et le caractère de soulignement sont autorisés. Les mots réservés ne peuvent être utilisés comme identificateurs.
Remarque:
Le .NET SDK déconseille l'utilisation de caractères de soulignement au début des identificateurs, car ce symbole est réservé au système.
-
but.... do we have a reason to forbid that?
i forbid numbers just because %20%20 must be left as 2 encoded url spaces, and %20% must never be considered as an HFS symbol.
consider that we must not comply with .NET, every language has its rules for identifiers.
java allows unicode characters, like Φ :)