remove special characters from string

cpampas

Registered User.
Local time
Today, 00:16
Joined
Jul 23, 2012
Messages
221
Hi,

I ve been using the following function to remove special characters, specific to some languages:

Code:
Public Function TiraAcento(sTexto As String) As String
'Retorna o texto sem acentuação
Dim Carac_esp, C_especial, C_subst As String
Dim F_tam As Integer, F_pos As Integer
Dim conta_letra As Integer, conta_pos As Integer
Dim Fonte As String
'
Fonte = sTexto
C_especial = "ñøŸûŽžïŠáàãâäÁÀÃÂÄóòõôöÓÒÕÔÖÉÈÊËéèêëíìïÍÌÏúùûüÚÙÛÜçÇöü"
C_subst = "noYuZziSaaaaaAAAAAoooooOOOOOEEEEeeeeiiiIIIuuuuUUUUcCou"

F_tam = Len(Fonte)

For conta_letra = 1 To F_tam
    Carac_esp = Mid$(Fonte, conta_letra, 1)
    F_pos = InStr(1, C_especial, Carac_esp, vbBinaryCompare)
If F_pos > 0 Then
Mid(Fonte, conta_letra, 1) = Mid(C_subst, F_pos, 1)
End If
Next conta_letra
TiraAcento = Fonte
End Function

the problem now is that I need to add some swedish and eastern european special character that computer settings wont recognize :

ęåşłęðüīộươäūảšūŽžčřě 'Tried to add this line to variable C_especial
easleouiouoauasuZzcre 'Tried to add this line to variable C_subst

if add this new set of characters my access does not recognize some of them, adding question marks instead
 
Another approach may be to store character codes in a table and examine your text vs. a Chr() or more likely ChrW() function.
 
I will probably have to store in a table, the characters that my function cannot deal with,and do match with ChrW().
Thanks for your help
 
I will probably have to store in a table, the characters that my function cannot deal with,and do match with ChrW().
Thanks for your help
Sure, good luck with the project!
 

Users who are viewing this thread

Back
Top Bottom