//================================================================//
// Funcao........: Remocao de acentuacao (REMACENT)
// Programador...: Marcos Antonio Gambeta
// Atualizacao...: Leomar Cleudson Costa
// Implementado para remover os acentos de toda tabela
// com campos tipo Char e pedir o nome da tabela
// 15/08/2009 (vc pode incluir novos caracteres na funcao.
// Contato.......: dicasdeprogramacao@yahoo.com.br
// Website.......: http://dicasprog.codigolivre.org.br
//================================================================//
// Linguagem.....: CA-Clipper 5.2/5.3
// Bibliotecas...:
// Plataforma....: DOS/Windows
//================================================================//
clear
ttab:=space(8)
@ 10,10 say "Tabela.:"
@ 10,19 get ttab pict '@!'
read
use (ttab) alias tab new
DBgoTop()
A=fcount()
for X=1 to A
if type(field(X))="C"
NOMECAMPO=field(X)
DBgotop()
while !eof()
texto:=alltrim(&NOMECAMPO)
texto:=remacent(texto)
field->&NOMECAMPO:=texto
skip
end
endif
next
@ 11,10 SAY 'Remocao de acentos concluida com sucesso '
return(.t.)
*
Function RemAcent ( cTexto )
// acento agudo
cTexto := StrTran( cTexto, " ", "a" )
cTexto := StrTran( cTexto, "‚", "e" )
cTexto := StrTran( cTexto, "¡", "i" )
cTexto := StrTran( cTexto, "¢", "o" )
cTexto := StrTran( cTexto, "£", "u" )
cTexto := StrTran( cTexto, "µ", "A" )
cTexto := StrTran( cTexto, "", "E" )
cTexto := StrTran( cTexto, "Ö", "I" )
cTexto := StrTran( cTexto, "à", "O" )
cTexto := StrTran( cTexto, "é", "U" )
// acento circunflexo
cTexto := StrTran( cTexto, "ƒ", "a" )
cTexto := StrTran( cTexto, "ˆ", "e" )
cTexto := StrTran( cTexto, "Œ", "i" )
cTexto := StrTran( cTexto, "“", "o" )
cTexto := StrTran( cTexto, "–", "u" )
cTexto := StrTran( cTexto, "¶", "A" )
cTexto := StrTran( cTexto, "Ò", "E" )
cTexto := StrTran( cTexto, "×", "I" )
cTexto := StrTran( cTexto, "â", "O" )
cTexto := StrTran( cTexto, "ê", "U" )
// til
cTexto := StrTran( cTexto, "Æ", "a" )
cTexto := StrTran( cTexto, "ä", "o" )
cTexto := StrTran( cTexto, "Ç", "A" )
cTexto := StrTran( cTexto, "å", "O" )
cTexto := StrTran( cTexto, "™", "O" )
cTexto := StrTran( cTexto, "Ž", "A" )
cTexto := StrTran( cTexto, "†", "A" )
// ce-cedilha
cTexto := StrTran( cTexto, "‡", "c" )
cTexto := StrTran( cTexto, "€", "C" )
// trema
cTexto := StrTran( cTexto, "", "u" )
cTexto := StrTran( cTexto, "š", "U" )
// crase
cTexto := StrTran( cTexto, "…", "a" )
cTexto := StrTran( cTexto, "Š", "e" )
cTexto := StrTran( cTexto, "", "i" )
cTexto := StrTran( cTexto, "•", "o" )
cTexto := StrTran( cTexto, "—", "u" )
cTexto := StrTran( cTexto, "·", "A" )
cTexto := StrTran( cTexto, "Ô", "E" )
cTexto := StrTran( cTexto, "Þ", "I" )
cTexto := StrTran( cTexto, "ã", "O" )
cTexto := StrTran( cTexto, "ë", "U" )
//outros caracteres
cTexto := StrTran( cTexto, "§", "." )
cTexto := StrTran( cTexto, "¦", "." )
cTexto := StrTran( cTexto, '"', "" )
Return cTexto
---
Notas da Moderação (Maligno):
1) A mensagem foi editada apenas para a inserção das tags de indentação de código, a fim de facilitar a visualização do código. Por favor, no futuro, insira essas tags, mesmo em códigos mais simples.
2) O tópico foi movido da seção "CA-Clipper", uma vez que seu conteúdo diverge dos objetivos daquela seção, onde só podem constar mensagens que lancem ou discutam dúvidas técnicas.