Fórum Acentuação #152842

08/04/2003

0

Olá pessoal,

Alguém conhece uma rotina que elimine acentuação dentro de uma cadeia de caracteres, por exemplo cora[b:8847576fc0]çã[/b:8847576fc0]o para cora[b:8847576fc0]ca[/b:8847576fc0]o?

Grato pela atenção,


Marioguedes

Marioguedes

Responder

Posts

08/04/2003

Anonymous

Crie esta função
-------------------

function FiltraAcento(voldstr : string): string;
var x : integer;
vcaracter : string;
begin
Result := ´´;
for x := 1 to length(voldstr) do
begin
vcaracter := voldstr[x];
If voldstr[x] in [´Ã´,´Á´,´Ä´,´Â´,´À´] then
vcaracter := ´A´;
If voldstr[x] in [´ã´,´á´,´ä´,´â´,´à´] then
vcaracter := ´a´;
If voldstr[x] in [´É´,´Ê´,´Ë´,´È´] then
vcaracter := ´E´;
If voldstr[x] in [´é´,´ê´,´ë´,´è´] then
vcaracter := ´e´;
If voldstr[x] in [´Í´,´Î´,´Ï´,´Ì´] then
vcaracter := ´I´;
If voldstr[x] in [´í´,´î´,´ï´,´ì´] then
vcaracter := ´i´;
If voldstr[x] in [´Ó´,´Ô´,´Ö´,´Ò´,´Õ´] then
vcaracter := ´O´ ;
If voldstr[x] in [´ó´,´ô´,´ö´,´ò´,´õ´] then
vcaracter := ´o´ ;
If voldstr[x] in [´Ú´,´Û´,´Ü´,´Ù´] then
vcaracter := ´U´;
If voldstr[x] in [´ú´,´û´,´ü´,´ù´] then
vcaracter := ´u´;
If voldstr[x] = ´º´ then
vcaracter := ´o.´ ;
If voldstr[x] = ´ª´ then
vcaracter := ´a.´;
If voldstr[x] = ´Ç´ then
vcaracter := ´C´;
If voldstr[x] = ´ç´ then
vcaracter := ´c´;

Result := Result + vcaracter ;
end;
end;



execute
--------
coloque por exemplo no evento on exit do edit1.

procedure Tedit1.exit....
begin
Edit1 := FiltraAcento(Edit1.Text);
end;


Responder

Gostei + 0

08/04/2003

Marioguedes

Valeu clodomir.


Responder

Gostei + 0

30/04/2003

Wgm8

Inseri um TEdit

Inseri a function acima, e a procedure do OnExit, mas quando vou compilar ele dá a menssagem:

[Error] Acento.pas(63): Incompatible types: ´TEdit´ and ´String´

O que está errado?


Responder

Gostei + 0

05/05/2003

Wgm8

:cry: Caramba será tão dificil assim pra ninguém responder... :?:


Responder

Gostei + 0

05/05/2003

Marcelo.c

Inseri um TEdit Inseri a function acima, e a procedure do OnExit, mas quando vou compilar ele dá a menssagem: [Error] Acento.pas(63): Incompatible types: ´TEdit´ and ´String´ O que está errado?


No código:

procedure Tedit1.exit....
begin
Edit1 := FiltraAcento(Edit1.Text);
end;

onde está apenas [b:6e4c893cce]Edit1[/b:6e4c893cce] deve-se colocar [b:6e4c893cce]Edit1.Text[/b:6e4c893cce]


Responder

Gostei + 0

05/05/2003

Wgm8

Esta função funciona certinho, só que quando ele altera ele manda o cursor pra o inicio da linha, como manter o cursor?


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar