Problems with Buscar with Gambas in SQLite3
Posted
#1
(In Topic #1816)
Enthusiast

I'm trying to find the descriptions of my data base in Spanish and I have a problem that can't be resolved. The problem is that 'Raúl' has 4 characters and Len or String. Len counts it as 4 but when it passes through the hole in reality it passes 5 characters and two are 'ú' and represents it as a vertical rhombus with a question sign that cannot be asked here. Someone knows what happens. Thank you.
Code (gambas)
Public Function acentoGuion(cadena As String) As String ' cadena = 'Raúl' Dim cadenaNueva As String Dim bBandera As Boolean = False For i As Integer = 0 To String.Len(cadena) - 1 ' Verifica si vocales con acento o no "áéíóúÁÉÍÓÚaeiouAEIOU" If InStr("áéíóúÁÉÍÓÚ", cadena[i]) > 0 Then bBandera = True cadenaNueva &= "_" Else cadenaNueva &= cadena [i]End If Next Return IIf(bBandera, cadenaNueva, cadena) End
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Enthusiast

See here:
/lang/conv - Gambas Documentation
If you want to remove diacritics, you can use the appropriate gb.util function:
/comp/gb.util/string/removediacritics - Gambas Documentation
However, with the gb.db2 and gb.db2.form components, I have no problems loading diacritics and searching for words with DB.Find.
/comp/gb.db2/db/find - Gambas Documentation
Posted
Enthusiast

Thank you so much for your help. This is my final solution.
Code (gambas)
Public Function acentoGuion(cadena As String) As String Dim cadenaNueva As String Dim bBandera As Boolean = False For i As Integer = 0 To Len(cadena) - 1 ' Verifica si vocales con acento o no "áéíóúÁÉÍÓÚaeiouAEIOU" If InStr("áéíóúÁÉÍÓÚ", cadena[i]) > 0 Then bBandera = True cadenaNueva &= "_" i += 1 Else cadenaNueva &= cadena [i]End If Next Return IIf(bBandera, cadenaNueva, cadena) End
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Enthusiast

Gambas provides the DB class for less experienced users (like me
I'm attaching a small example that should work on all three major databases used in GNU/Linux.
FindTestDiacritics-0.0.1.tar.gz
1 guest and 0 members have just viewed this.




