Problem Text with characters with accents

ciginfo

Well-Known Member
Licensed User
Longtime User
Hi
when I load text with characters with accents from a database on a server into a string of my appli, Label.text displays "Null". If I load text with characters without accent it is OK.
I thought in a precedent post it was the length of the text, but not, it is the présence of characters with accents.
How can I fix this problem?
Thank you
 

ciginfo

Well-Known Member
Licensed User
Longtime User
I load with Jobdone.

B4X:
Sub ExtraitListeAffiche
   ProgressDialogShow("Mise à jour des données")
    ExecuteRemoteQuery("SELECT id, nom, adresse, telephone, mail, longitude, latitude, ville, departement, what, texte, url, url_image, ce_moment FROM kindabreak WHERE ce_moment = 1 ORDER BY id", AFFICHE_LIST)
End Sub
ExtraitListeAffiche is called in Activity_Create, then
B4X:
Sub JobDone(Job As HttpJob)
   ProgressDialogHide
   If Job.Success Then
   Dim RES As String
      RES = Job.GetString
      Log("Response from server: " & RES)
      Dim parser As JSONParser
      parser.Initialize(RES)
      Select Job.JobName
         
         Case AFFICHE_LIST
            Dim AFFICHE As List
            AFFICHE = parser.NextArray 'returns a list with maps
            For i = 0 To AFFICHE.Size - 1
               Dim M As Map
               M = AFFICHE.Get(i)
               Dim  Nom, Adresse, Telephone, Mail, Ville, Texte, URL, URL_Image As String 
               Dim Index,Departement, What, Ce_moment As Int
               Dim Longitude, Latitude As Double
               Index = M.Get("id")
               Nom = M.Get("nom")
               Adresse = M.Get("adresse")
               Ville = M.Get("ville")
               Departement = M.Get("departement")
               Longitude = M.Get("longitude")
               Latitude = M.Get("latitude")
               Telephone = M.Get("telephone")
               Mail = M.Get("mail")
               What = M.Get("what")
               Texte = M.Get("texte")
               URL = M.Get("url")
               URL_Image = M.Get("url_image")
               Ce_moment = M.Get("ce_moment")
               
               ListViewAffiche.AddTwoLines2(Nom, Adresse & ", " & Ville & " " & Departement & ". Tel: " & Telephone, M)
            Next
Puis
B4X:
Sub ListViewAffiche_ItemClick (Position As Int, Value As Object)

mapData = Value
   MonNom = mapData.Get("nom")
   MonTexte = mapData.Get("texte")
   MyURL_Image = mapData.Get("url_image")
   MyURL_Site = mapData.Get("url")
   Mylatitude = mapData.Get("latitude")
   Mylongitude = mapData.Get("longitude")
'Remplit Scroll Ecran et LblTitre
   FillScrollEcran
   LblTitre.Text = MonNom
   LblEcran.Text = MonTexte
'Remplit ImgEcran
   Dim  job5 As HttpJob
    job5.Initialize("Image_ecran", Me)
   job5.Download(MyURL_Image)
'xxxxx Ouvre la vue Ecran       xxxxxxxxx   
PnlEcran.Visible = True
PnlEcran.BringToFront
End Sub
In MySql "texte" is type (text), collation (utf8_general_ci).
It the same problem with others columns type (VarChar).
When there is an accent into a data type (text) or (VarChar) the correspondant string in my appli display"Null". If I remove the accent in the DB it works fine.
An Idea?
Thank you
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
OK. We have to add this line below in "connection.php" and it works fine.
B4X:
mysql_query("SET CHARACTER SET utf8");
Thank you to all the team
 
Upvote 0
Top