1with AdaBase;
2with Connect;
3with CommonText;
4with Ada.Text_IO;
5with Ada.Wide_Text_IO;
6with Ada.Wide_Wide_Text_IO;
7with AdaBase.Results.Sets;
8
9procedure UTF8 is
10
11   package CON renames Connect;
12   package TIO renames Ada.Text_IO;
13   package WIO renames Ada.Wide_Text_IO;
14   package WWO renames Ada.Wide_Wide_Text_IO;
15   package ARS renames AdaBase.Results.Sets;
16   package CT  renames CommonText;
17
18begin
19
20   CON.connect_database;
21
22   TIO.Put_Line ("Use terminal encoding UTF-8 or ISO8859-1");
23   TIO.Put_Line ("Either UTF8 fields or string fields will look right, " &
24                 "but not both");
25   declare
26      sql  : constant String := "SELECT * FROM funny_names";
27      stmt : CON.Stmt_Type := CON.DR.query (sql);
28      row  : ARS.Datarow;
29   begin
30      loop
31         row := stmt.fetch_next;
32         exit when row.data_exhausted;
33         TIO.Put_Line ("");
34         TIO.Put_Line ("    UTF8: " & row.column ("first_name").as_utf8 &
35                       " " & row.column ("surname").as_utf8);
36         TIO.Put_Line ("  STRING: " & row.column ("first_name").as_string &
37                       " " & row.column ("surname").as_string);
38         WIO.Put_Line (" WSTRING: " & row.column ("first_name").as_wstring &
39                       " " & row.column ("surname").as_wstring);
40         WWO.Put_Line ("WWSTRING: " & row.column ("first_name").as_wwstring &
41                       " " & row.column ("surname").as_wwstring);
42      end loop;
43   end;
44
45   CON.DR.disconnect;
46
47end UTF8;
48