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
|
unit tvalc;
interface
const
HasErrors : boolean = false;
Silent : boolean = true;
CheckVal : boolean = true;
SuccessCount : longint = 0;
FailCount : longint = 0;
type
TCharSet = set of char;
const
ValidNumeralsBase2 : TCHarSet = ['0'..'1'];
ValidNumeralsBase8 : TCHarSet = ['0'..'7'];
ValidNumeralsBase10 : TCHarSet = ['0'..'9'];
ValidNumeralsBase16 : TCHarSet = ['0'..'9','a'..'f','A'..'F'];
SpecialCharsFirst : TCharSet = [' ',#9,'x','X','$','&','%','+','-'];
SpecialCharsSecond : TCharSet = [#0];
type
ValTestType =
(ValShouldFail,
ValShouldSucceed,
ValShouldSucceedAfterRemovingTrail);
function Display(const s : string) : string;
implementation
function Display(const s : string) : string;
var
res,ordval : string;
i : longint;
quoted : boolean;
begin
res:='"';
quoted:=false;
for i:=1 to length(s) do
if ord(s[i])<32 then
begin
if quoted then
res:=res+'''';
str(ord(s[i]),ordval);
res:=res+'#'+ordval;
quoted:=false;
end
else
begin
if not quoted then
res:=res+'''';
quoted:=true;
res:=res+s[i];
end;
if quoted then
res:=res+'''';
res:=res+'"';
Display:=res;
end;
end.
|