-
Notifications
You must be signed in to change notification settings - Fork 10
/
DWFiredacUtils.pas
78 lines (68 loc) · 2.13 KB
/
DWFiredacUtils.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
unit DWFiredacUtils;
interface
uses System.Classes, System.Variants, System.SysUtils, System.StrUtils;
function ReplaceSpecialChars(Texto:string):string;
function GetKeyFromParams(AParams: TStringList):Word;
function GetShiftStateFromParams(AParams: TStringList):TShiftState;
implementation
function ReplaceSpecialChars(Texto:string):string;
Var A : Integer ;
Letra : AnsiChar ;
AnsiStr, Ret : AnsiString ;
function TiraAcento( const AChar : AnsiChar ) : AnsiChar ;
begin
case AChar of
'à','á','ã','ä','â','ª' : Result := 'a' ;
'À','Á','Ã','Ä','Â' : Result := 'A' ;
'è','é', 'ë','ê' : Result := 'e' ;
'È','É', 'Ë','Ê' : Result := 'E' ;
'ì','í', 'ï','î' : Result := 'i' ;
'Ì','Í', 'Ï','Î' : Result := 'I' ;
'ò','ó','õ','ö','ô','º' : Result := 'o' ;
'Ò','Ó','Õ','Ö','Ô' : Result := 'O' ;
'ù','ú', 'ü','û' : Result := 'u' ;
'Ù','Ú', 'Ü','Û' : Result := 'U' ;
'ç' : Result := 'c' ;
'Ç' : Result := 'C' ;
'ñ' : Result := 'n' ;
'Ñ' : Result := 'N' ;
else
Result := AChar ;
end;
end ;
begin
Result := '' ;
Ret := '' ;
AnsiStr := AnsiString( Texto );
For A := 1 to Length( AnsiStr ) do
begin
Letra := TiraAcento( AnsiStr[A] ) ;
if not (Letra in [#32..#126,#13,#10,#8]) then {Letras / numeros / pontos / sinais}
Letra := ' ' ;
Ret := Ret + Letra ;
end ;
Result := String(Ret)
End;
function GetKeyFromParams(AParams: TStringList):Word;
begin
try
Result:= StrToIntDef(AParams.Values['which'] ,0);
except
Result:=0;
end;
end;
function GetShiftStateFromParams(AParams: TStringList):TShiftState;
var
Modif:string;
begin
Result:=[];
try
Modif:= AParams.Values['modifiers'];
if ContainsStr(Modif, 'SHIFT_MASK') then Include(Result, ssShift);
if ContainsStr(Modif, 'CTRL_MASK') then Include(Result, ssCtrl);
if ContainsStr(Modif, 'ALT_MASK') then Include(Result, ssAlt);
except
Result:=[];
end;
end;
end.