segunda-feira, 4 de março de 2013

Procedure RetiraAcento



Function RetiraAcento(Str:String): String;
{Remove caracteres acentuados de uma string}
Const ComAcento = 'àâêôûãõáéíóúçüÀÂÊÔÛÃÕÁÉÍÓÚÇÜ';
  SemAcento = 'aaeouaoaeioucuAAEOUAOAEIOUCU';
Var
x : Integer;
Begin
 For x := 1 to Length(Str) do Begin
   if Pos(Str[x],ComAcento)<>0 Then begin
      Str[x] := SemAcento[Pos(Str[x],ComAcento)];
  end;
  end;
 Result := Str;
end;


//Exemplo de uso
RetiraAcento(cdsRellatorio.FieldByName('CAMPO').AsString);
RetiraAcento(Trim(cdsRellatorio.FieldByName('CAMPO').AsString));
RetiraAcento('Comentários Computação Depressão');




Nenhum comentário:

Postar um comentário