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
|
{ %skiptarget=win32,win64,wince,os2,emx,go32v2,msdos }
{ This test is only useful if the local codepage is utf-8 which
usually not the case on windows (and never can be the case on OS/2)
}
{$codepage utf-8}
{$mode objfpc}
{$ifdef go32v2}
{$define USE_INTERNAL_UNICODE}
{$endif}
{$ifdef USE_INTERNAL_UNICODE}
{$define USE_FPWIDESTRING_UNIT}
{$define USE_UNICODEDUCET_UNIT}
{$define USE_CPALL_UNIT}
{$endif}
uses
{$ifndef USE_INTERNAL_UNICODE}
{$ifdef unix}
{$ifdef darwin}iosxwstr{$else}cwstring{$endif},
{$endif}
{$endif ndef USE_INTERNAL_UNICODE}
{$ifdef USE_UNICODEDUCET_UNIT}
unicodeducet,
{$endif}
{$ifdef USE_FPWIDESTRING_UNIT}
fpwidestring,
{$endif}
{$ifdef USE_CPALL_UNIT}
cpall,
{$endif}
SysUtils;
{$i+}
var
t: text;
w: widestring;
u: unicodestring;
a: ansistring;
wc: widechar;
begin
assign(t,'twide3.txt');
rewrite(t);
writeln(t,'łóżka');
close(t);
reset(t);
try
read(t,wc);
if wc<>'ł' then
raise Exception.create('wrong widechar read: '+inttostr(ord(wc))+'<>'+inttostr(ord('ł')));
except
close(t);
// erase(t);
raise;
end;
reset(t);
try
readln(t,a);
w:=a;
if (w<>'łóżka') then
raise Exception.create('wrong ansistring read');
except
close(t);
erase(t);
raise;
end;
reset(t);
try
readln(t,w);
if (w<>'łóżka') then
raise Exception.create('wrong widestring read');
except
close(t);
erase(t);
raise;
end;
reset(t);
try
readln(t,u);
if (u<>'łóżka') then
raise Exception.create('wrong unicodestring read');
finally
close(t);
erase(t);
end;
readstr(u,a);
if u<>a then
raise Exception.create('wrong readstr(u,a)');
readstr(w,a);
if w<>u then
raise Exception.create('wrong readstr(w,a)');
end.
|