controlled_io_20240401.0.1_0cfe3ed5/tests/src/controlled_utf.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
-- Test of Controlled_IO.Text and Controlled_IO.UTF: convert an OS-format text file to UTF
-- Copyright (C) by PragmAda Software Engineering
-- Released under the terms of the BSD 3-Clause license; see https://opensource.org/licenses

with Ada.Characters.Conversions;
with Ada.Command_Line;
with Controlled_IO.Text;
with Controlled_IO.UTF;

procedure Controlled_UTF is
   Input  : Controlled_IO.File_Handle := Controlled_IO.Opened  (Ada.Command_Line.Argument (1) );
   Output : Controlled_IO.File_Handle := Controlled_IO.Created (Ada.Command_Line.Argument (2) );
begin -- Controlled_UTF
   Copy : loop
      exit Copy when Input.End_Of_File;

      Controlled_IO.UTF.Put_Line
         (File => Output, Item => Ada.Characters.Conversions.To_Wide_Wide_String (Controlled_IO.Text.Next_Line (Input) ) );
   end loop Copy;
end Controlled_UTF;