function Trim(const S: string): String;
Trims leading and trailing spaces and control characters from the given string S.