去除全角半角字符

//去除左边的全角

function MyTrimLeft(const S: string): string;

var

  ci, sl: integer;

  c: char;

begin

  ci := 1; sl := length(S);

  while (ci <= sl) do

  begin

    c := S[ci];

    case c of

      ' ': inc(ci);

      #161: if (ci < sl) and (S[ci + 1] = c) then

          inc(ci, 2);

    else

      break;

    end;

  end;

  Result := Copy(S, ci, sl);

end;

//去除右边的全角

function MyTrimRight(const S: string): string;

var

  ci, sl: integer;

  c: char;

begin

  sl := length(S);

  ci := sl;

  while (ci >= 0) do

  begin

    c := S[ci];

    case c of

      ' ': Dec(ci);

      #161: if (ci <= sl) and (S[ci - 1] = c) then

          Dec(ci, 2);

    else

      break;

    end;

  end;

  Result := Copy(S, 1, ci);

end;

原文地址:https://www.cnblogs.com/djcsch2001/p/2035710.html