Acentuação
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,
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
Curtidas 0
Respostas
Anonymous
08/04/2003
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;
-------------------
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;
GOSTEI 0
Marioguedes
08/04/2003
Valeu clodomir.
GOSTEI 0
Wgm8
08/04/2003
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?
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?
GOSTEI 0
Wgm8
08/04/2003
:cry: Caramba será tão dificil assim pra ninguém responder... :?:
GOSTEI 0
Marcelo.c
08/04/2003
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]
GOSTEI 0
Wgm8
08/04/2003
Esta função funciona certinho, só que quando ele altera ele manda o cursor pra o inicio da linha, como manter o cursor?
GOSTEI 0