with Ada.Strings.Fixed; with Ada.Text_IO; procedure StringInsertSpaces is s : String(1..10) := (others => ' '); begin s(1) := 'a'; s(2) := 'b'; for i in 1 .. s'length + 5 loop Ada.Text_IO.Put_Line(""""&s&""""); Ada.Strings.Fixed.Insert(s, 2, "x"); end loop; end StringInsertSpaces; -- Output: -- "ab " -- "axb " -- "axxb " -- "axxxb " -- "axxxxb " -- "axxxxxb " -- "axxxxxxb " -- "axxxxxxxb " -- "axxxxxxxxb" -- -- raised ADA.STRINGS.LENGTH_ERROR : a-strfix.adb:360 -- -- Ie, Ada.Strings.Fixed.Insert treats spaces differently -- than all other characters. It will happily throw away -- spaces that fall off the end of the string, but it will -- raise an exception when any other kind of character would -- be similarly discarded. -- -- See also StringInsert