Commit 486fd7f5 by Vincent Celier Committed by Arnaud Charlet

2008-08-05 Vincent Celier <celier@adacore.com>

	* s-wchwts.adb:
	(Wide_String_To_String): Returns a String with the same 'First as its
	parameter S.
	(Wide_Wide_String_To_String): Ditto
	
	* s-wchwts.ads:
	(Wide_String_To_String): Document that the lowest index of the returned
	String is equal to S'First.

From-SVN: r138708
parent c336d2c7
...@@ -88,16 +88,16 @@ package body System.WCh_WtS is ...@@ -88,16 +88,16 @@ package body System.WCh_WtS is
(S : Wide_String; (S : Wide_String;
EM : WC_Encoding_Method) return String EM : WC_Encoding_Method) return String
is is
R : String (1 .. 5 * S'Length); -- worst case length! R : String (S'First .. S'First + 5 * S'Length); -- worst case length!
RP : Natural; RP : Natural;
begin begin
RP := 0; RP := R'First - 1;
for SP in S'Range loop for SP in S'Range loop
Store_UTF_32_Character (Wide_Character'Pos (S (SP)), R, RP, EM); Store_UTF_32_Character (Wide_Character'Pos (S (SP)), R, RP, EM);
end loop; end loop;
return R (1 .. RP); return R (R'First .. RP);
end Wide_String_To_String; end Wide_String_To_String;
-------------------------------- --------------------------------
...@@ -108,17 +108,17 @@ package body System.WCh_WtS is ...@@ -108,17 +108,17 @@ package body System.WCh_WtS is
(S : Wide_Wide_String; (S : Wide_Wide_String;
EM : WC_Encoding_Method) return String EM : WC_Encoding_Method) return String
is is
R : String (1 .. 7 * S'Length); -- worst case length! R : String (S'First .. S'First + 7 * S'Length); -- worst case length!
RP : Natural; RP : Natural;
begin begin
RP := 0; RP := R'First - 1;
for SP in S'Range loop for SP in S'Range loop
Store_UTF_32_Character (Wide_Wide_Character'Pos (S (SP)), R, RP, EM); Store_UTF_32_Character (Wide_Wide_Character'Pos (S (SP)), R, RP, EM);
end loop; end loop;
return R (1 .. RP); return R (R'First .. RP);
end Wide_Wide_String_To_String; end Wide_Wide_String_To_String;
end System.WCh_WtS; end System.WCh_WtS;
...@@ -54,7 +54,8 @@ package System.WCh_WtS is ...@@ -54,7 +54,8 @@ package System.WCh_WtS is
-- that normal (non-wide character) mode holds at the start and end of -- that normal (non-wide character) mode holds at the start and end of
-- the result string. EM indicates the wide character encoding method. -- the result string. EM indicates the wide character encoding method.
-- Note: in the WCEM_Brackets case, we only use the brackets encoding -- Note: in the WCEM_Brackets case, we only use the brackets encoding
-- for characters greater than 16#FF#. -- for characters greater than 16#FF#. The lowest index of the returned
-- String is equal to S'First.
function Wide_Wide_String_To_String function Wide_Wide_String_To_String
(S : Wide_Wide_String; (S : Wide_Wide_String;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment