-
Notifications
You must be signed in to change notification settings - Fork 2
/
MyStrs.pas
executable file
·75 lines (66 loc) · 1.8 KB
/
MyStrs.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
Unit MyStrs;
interface
var BreakChars : Set of Char = [',',' ','[',']','{','}','(',')',':',';','.','^',
'&','*','!','#','$','/','\','"','%','>','<',
'-','+','=','|','?',#13,#10,#9,#26,#12,'@'];
function STRALLUP(s : string) : string;
function stralldown(s : string) : string;
function StrCap(s : string) : string;
function StrCapFirst(s : string) : string;
implementation uses sysutils;
function STRALLUP(s : string) : string;
begin
Result := AnsiUpperCase(s);
end;
function stralldown(s : string) : string;
begin
Result := AnsiLowerCase(s);
end;
function StrCap(s : string) : string;
var i : Integer;
ns,ts : string;
fst : boolean;
begin
i := 1; ns := ''; fst := true;
repeat
while (i <= Length(s)) and (s[I] in BreakChars) do
begin
ns := ns + s[i];
Inc(i);
end;
if i > Length(s) then break;
ts := '';
while (i <= Length(s)) and (not (s[i] in BreakChars)) do
begin
ts := ts + s[i];
Inc(i);
end;
ts := AnsiLowerCase(ts);
if (ts = 'dj')or(ts = 'cj')or(ts = 'vj')or(ts = 'd.j.')or(ts = 'c.j.')or(ts = 'v.j.') then
begin
ts := AnsiUpperCase(ts);
end else
if fst then
begin
fst := false;
ts[1] := AnsiUpperCase(ts[1])[1];
end else
if ts<>'' then
if (ts <> 'for')and(ts <> 'or')and(ts<>'a')and(ts<>'the')and(ts<>'at')and(ts<>'de')and(ts<>'la')and(ts<>'des')and(ts<>'of')and(ts<>'to')
then
begin
ts[1] := AnsiUpperCase(ts[1])[1];
end;
ns := ns+ts{ + ' '};
until i > Length(s);
Result := Trim(ns);
end;
function StrCapFirst(s : string) : string;
var i : Integer;
begin
i := 1;
while (i <= Length(s)) and (s[i] in BreakChars) do Inc(i);
if i <= length(s) then s[i] := AnsiUpperCase(s[i])[1];
Result := s;
end;
end.