Top Prev Next Up Down

StripC

Strip or trim the result. Because we are working with 21-bit characters and all indexing is based on theese 21-bit characters.

function stripC(value:Cfix;left:Cfix:=CFix_Space;right:Cfix:=CFix_Space) return CFix ;

function stripC(value:String;left:String:=" ";right:String:=" ") return String ;

function stripC(value:CVar;left:CFix:=CFix_Space;right:CFix:=CFix_Space) return CVar;

Examples:
001| v10:String:="1234567890";
002| w:String:=(3=>'3',4=>'4',5=>'5');
003| x8:String:=" ABC ";
004| y14:String:="abcdefghijklmn";
005| y15:String:="abcdefghijklmnU";
006| z:String(1 .. 0);


[1] Ada.Text_IO.Put_Line ( "stripC(y14).>" & stripC(y14) & "<");
  result: stripC(y14).>abcdefghijklmn<
[2] Ada.Text_IO.Put_Line ( "stripC(w,""3"",""5"")>" & stripC(w,"3","5") & "<");
  result: stripC(w,"3","5")>4<
  3” is removed from the beginning and “5” is removed from the end.
[3] Ada.Text_IO.Put_Line ( "stripC(x8).>" & stripC(x8) & "<");
  result: stripC(x8).>ABC<
[4] Ada.Text_IO.Put_Line ( "stripC(z).>" & stripC(z) & "<");
  result: stripC(z).><
  Because then string donnot contain any storage units then nothing is ‘stripped’ away.
[5] Ada.Text_IO.Put_Line ( "stripC(x8,right=>"""").> & stripC(x8,right=>"") & “<”);
  result: stripC(x8,right=>"").>ABC <
  Odd but it is correct. Same as with stripC(x8,” “,””) which explains to result. The notation “”
  specifies that no units are removed.
[6] Ada.Text_IO.Put_Line ( "stripC(x8,left=>"""").> & stripC(x8,left=>"") & “<”);
  result: stripC(x8,left=>"").> ABC<
  Odd but it is correct. Same as with stripC(x8,”“,” ”) which explains to result. The notation “”
  specifies that no units are removed.
[7] Ada.Text_IO.Put_Line ( "stripC(v10,""12"",""098"").> & stripC(v10,"12","098") & "<");
  result: stripC(v10,"12","098").>34567<
  Note that the right-parameter has the storage units in another order than in the v10-string.
  stripC is closely related to ‘trim’, but this is the solution for package Y2018-Text-Core-Str.