summaryrefslogtreecommitdiff
path: root/tests/test/tunistr5.pp
blob: b09a333a54d4084e1dead3d5b09f129d82ec6589 (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
{$codepage utf-8}

var
  ws: unicodestring;
  us: UCS4String;
begin
// the compiler does not yet support characters which require
// a surrogate pair in utf-16
//  ws:='鳣ćçŹ你';
//  so write the last character directly using a utf-16 surrogate pair
  ws:='鳣ćçŹ'#$d87e#$dc04;

  if (length(ws)<>8) or
     (ws[1]<>'é') or
     (ws[2]<>'ł') or
     (ws[3]<>'Ł') or
     (ws[4]<>'ć') or
     (ws[5]<>'ç') or
     (ws[6]<>'Ź') or
     (ws[7]<>#$d87e) or
     (ws[8]<>#$dc04) then
    halt(1);
  us:=UnicodeStringToUCS4String(ws);
  if (length(us)<>8) or
     (us[0]<>UCS4Char(unicodechar('é'))) or
     (us[1]<>UCS4Char(unicodechar('ł'))) or
     (us[2]<>UCS4Char(unicodechar('Ł'))) or
     (us[3]<>UCS4Char(unicodechar('ć'))) or
     (us[4]<>UCS4Char(unicodechar('ç'))) or
     (us[5]<>UCS4Char(unicodechar('Ź'))) or
     (us[6]<>UCS4Char($2F804)) or
     (us[7]<>UCS4Char(0)) then
    halt(2);
  ws:=UCS4StringToUnicodeString(us);
  if (length(ws)<>8) or
     (ws[1]<>'é') or
     (ws[2]<>'ł') or
     (ws[3]<>'Ł') or
     (ws[4]<>'ć') or
     (ws[5]<>'ç') or
     (ws[6]<>'Ź') or
     (ws[7]<>#$d87e) or
     (ws[8]<>#$dc04) then
    halt(3);
end.