tw2069.pp 557 B

12345678910111213141516171819
  1. { Source provided for Free Pascal Bug Report 2069 }
  2. { Submitted by "Sergey Kosarevsky" on 2002-08-07 }
  3. { e-mail: [email protected] }
  4. Const WhiteSpace = [' ',#0,#1,#2,#3,#4,#5,#6,#7,#8,#9,#10,#11,#12,#13,#14,#15,#16,#17,#18,#19,#20,#21,#22,#23,#24,#25,#26,#27,#28,#29,#30,#31];
  5. Function Trim(Const S:String):String;
  6. Var Ofs,Len:Integer;
  7. Begin
  8. Len:=Length(S);
  9. While (Len>0) And
  10. (S[Len] In WhiteSpace) Do Dec(Len);
  11. Ofs:=1;
  12. While (Ofs<=Len) And
  13. (S[Ofs] In WhiteSpace) Do Inc(Ofs);
  14. Exit(Copy(S,Ofs,1+Len-Ofs));
  15. End;
  16. Begin
  17. End.