summaryrefslogtreecommitdiff
path: root/tests/webtbs/tw13015.pp
blob: a7572de6dd3fe3f8e700f47e091bb234f81985d8 (plain)
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
program test;

{$ifdef FPC}
{$mode delphi}
{$endif}
{$ifdef windows}
{$apptype console}
{$endif}

{$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 unix}
 {$endif ndef USE_INTERNAL_UNICODE}
 {$ifdef USE_UNICODEDUCET_UNIT}
  unicodeducet,
 {$endif}
 {$ifdef USE_FPWIDESTRING_UNIT}
  fpwidestring,
 {$endif}
 {$ifdef USE_CPALL_UNIT}
  cpall,
 {$endif}
 Classes,SysUtils,uw13015;

procedure writefile(const fn: string);
var
  f:TStream;
  tc:TTestClass;
begin
  writeln('Write component with widestring property to stream');
  tc:=TTestClass.Create(nil);
  writeln('tc.Wstr=',tc.Wstr);
  write('tc.DumpAndCheck()');
  tc.DumpAndCheck;
     
  f:=TFileStream.Create(fn,fmCreate);
  try
    f.WriteComponent(tc);
  finally
    f.Free;
  end;

  tc.free;
end;


procedure readfile(const fn: string);
var
  f:TStream;
  tc:TTestClass;
begin
  writeln('Reading component with widestring property');
  f:=TFileStream.Create(fn,fmOpenRead);
  try
    tc:=TTestClass(f.ReadComponent(nil));
    if Assigned(tc) then
      begin
        writeln('tc.Wstr=',tc.Wstr);
        write('tc.DumpAndCheck()');
        tc.DumpAndCheck;
      end;
  finally
    f.Free;
  end;

  tc.free;
end;


const utf8str : array[0..84] of char=(
  'T','P','F','0',#010,'T','T','e','s','t','C','l','a','s','s',
  #000,#004,'W','s','t','r',#020,'9',#000,#000,#000,#208,#191,#209,#128,
  #208,#184,#208,#178,#208,#181,#209,#130,',',' ',#208,#191,#209,#128,#209,
  #139,#208,#178,#209,#150,#209,#130,#208,#176,#208,#189,#209,#140,#208,#189,
  #208,#181,' ','-',' ','p','r',#195,#188,'f','u','n','g',' ','s',
  'p','a',#195,#159,' ','g','u','t',#000,#000);

var
  f: file;
begin
  RegisterClasses([TTestClass]);

  WriteFile('test.bin');
  ReadFile('test.bin');
  DeleteFile('test.bin');
  
  assign(f,'tw13015-utf8.bin');
  rewrite(f,1);
  blockwrite(f,utf8str,sizeof(utf8str));
  close(f);
  ReadFile('tw13015-utf8.bin');
  DeleteFile('tw13015-utf8.bin');
end.