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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
{
*********************************************************************
Copyright (C) 2002-2005 by Florian Klaempfl
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*********************************************************************
}
function Trim(const S: unicodestring): unicodestring;
var
Ofs, Len: sizeint;
begin
len := Length(S);
while (Len>0) and (S[Len]<=' ') do
dec(Len);
Ofs := 1;
while (Ofs<=Len) and (S[Ofs]<=' ') do
Inc(Ofs);
result := Copy(S, Ofs, 1 + Len - Ofs);
end;
{ TrimLeft returns a copy of S with all blank characters on the left stripped off }
function TrimLeft(const S: unicodestring): unicodestring;
var
i,l:sizeint;
begin
l := length(s);
i := 1;
while (i<=l) and (s[i]<=' ') do
inc(i);
Result := copy(s, i, l);
end;
{ TrimRight returns a copy of S with all blank characters on the right stripped off }
function TrimRight(const S: unicodestring): unicodestring;
var
l:sizeint;
begin
l := length(s);
while (l>0) and (s[l]<=' ') do
dec(l);
result := copy(s,1,l);
end;
function UnicodeUpperCase(const s : UnicodeString) : UnicodeString;{$ifdef SYSUTILSINLINE}inline;{$endif}
begin
result:=widestringmanager.UpperUnicodeStringProc(s);
end;
function UnicodeLowerCase(const s : UnicodeString) : UnicodeString;{$ifdef SYSUTILSINLINE}inline;{$endif}
begin
result:=widestringmanager.LowerUnicodeStringProc(s);
end;
function UnicodeCompareStr(const s1, s2 : UnicodeString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
begin
result:=widestringmanager.CompareUnicodeStringProc(s1,s2);
end;
function UnicodeSameStr(const s1, s2 : UnicodeString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
begin
result:=widestringmanager.CompareUnicodeStringProc(s1,s2)=0;
end;
function UnicodeCompareText(const s1, s2 : UnicodeString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
begin
result:=widestringmanager.CompareTextUnicodeStringProc(s1,s2);
end;
function UnicodeSameText(const s1, s2 : UnicodeString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
begin
result:=widestringmanager.CompareTextUnicodeStringProc(s1,s2)=0;
end;
{ we've no templates, but with includes we can simulate this :) }
{$macro on}
{$define INWIDEFORMAT}
{$define TFormatString:=unicodestring}
{$define TFormatChar:=unicodechar}
Function UnicodeFormat (Const Fmt : UnicodeString; const Args : Array of const; Const FormatSettings: TFormatSettings) : UnicodeString;
{$i sysformt.inc}
{$undef TFormatString}
{$undef TFormatChar}
{$undef INWIDEFORMAT}
{$macro off}
Function UnicodeFormat (Const Fmt : UnicodeString; const Args : Array of const) : UnicodeString;
begin
Result:=UnicodeFormat(Fmt,Args,DefaultFormatSettings);
end;
Function UnicodeFormatBuf (Var Buffer; BufLen : Cardinal;
Const Fmt; fmtLen : Cardinal;
Const Args : Array of const; Const FormatSettings: TFormatSettings) : Cardinal;
Var
S,F : UnicodeString;
begin
Setlength(F,fmtlen);
if fmtlen > 0 then
Move(fmt,F[1],fmtlen*sizeof(Unicodechar));
S:=UnicodeFormat (F,Args);
If Cardinal(Length(S))<Buflen then
Result:=Length(S)
else
Result:=Buflen;
Move(S[1],Buffer,Result);
end;
Function UnicodeFormatBuf (Var Buffer; BufLen : Cardinal;
Const Fmt; fmtLen : Cardinal;
Const Args : Array of const) : Cardinal;
begin
Result:=UnicodeFormatBuf(Buffer,BufLEn,Fmt,FmtLen,Args,DefaultFormatSettings);
end;
Procedure UnicodeFmtStr(Var Res: UnicodeString; Const Fmt : UnicodeString; Const args: Array of const; Const FormatSettings: TFormatSettings);
begin
Res:=UnicodeFormat(fmt,Args);
end;
Procedure UnicodeFmtStr(Var Res: UnicodeString; Const Fmt : UnicodeString; Const args: Array of const);
begin
UnicodeFmtStr(Res,Fmt,Args,DefaultFormatSettings);
end;
function StrPLCopy(Dest: PWideChar; const Source: UnicodeString; MaxLen: SizeInt): PWideChar; overload;
var Len: SizeInt;
begin
Len := length(Source);
if Len > MaxLen then
Len := MaxLen;
Move(Source[1], Dest^, Len*sizeof(WideChar));
Dest[Len] := #0;
StrPLCopy := Dest;
end;
function StrPCopy(Dest: PWideChar; const Source: UnicodeString): PWideChar; overload;
begin
StrPCopy := StrPLCopy(Dest, Source, length(Source));
end;
|