我想编写一个 Ada 程序,用适用的 HTML 实体替换 Latin1 字符,但我的代码不起作用:text.txt
并且converted.txt
始终相同。我的导师说代码是正确的。提前致谢!
这是我的代码:
with Ada.Text_IO;
procedure Entity_Converter is
use Ada.Text_IO;
Source : File_Type;
Target : File_Type;
Source_Char : Character;
begin
Open (Source, In_File, "test.txt");
Create (Target, Out_File, "converted.txt");
while not End_Of_File (Source) loop
Get (Source, Source_Char);
case Source_Char is
when 'ä' =>
Put (Target, "ä");
when 'Ä' =>
Put (Target, "Ä");
when 'ö' =>
Put (Target, "ö");
when 'Ö' =>
Put (Target, "Ö");
when 'ü' =>
Put (Target, "ü");
when 'Ü' =>
Put (Target, "Ü");
when 'ß' =>
Put (Target, "ß");
when others =>
Put (Target, Source_Char);
end case;
end loop;
Close (Source);
Close (Target);
end Entity_Converter;