DALB Active Member Licensed User Jul 23, 2021 #1 Hello, Here is a syntax which doesn't work: B4X: Copy mot=mot.replace("é","e") In my language, for instance, the letter "é" can't be changed to "e" with the 'Replace' function. B4A returns this: android.database.sqlite.SQLiteException: near "diff�rents": syntax error (code 1): , while compiling: INSERT INTO bnotes VALUES (1, science, les diff�rents domaines de la science, analyse, 15/05/2021, 20210515, 0) You can see the sign in the word different. Is there a way to make it possible ? If someone comes here, thanks to him ! Every idea is welcome.
Hello, Here is a syntax which doesn't work: B4X: Copy mot=mot.replace("é","e") In my language, for instance, the letter "é" can't be changed to "e" with the 'Replace' function. B4A returns this: android.database.sqlite.SQLiteException: near "diff�rents": syntax error (code 1): , while compiling: INSERT INTO bnotes VALUES (1, science, les diff�rents domaines de la science, analyse, 15/05/2021, 20210515, 0) You can see the sign in the word different. Is there a way to make it possible ? If someone comes here, thanks to him ! Every idea is welcome.
DALB Active Member Licensed User Jul 23, 2021 #3 otherwise... How to detect an unknown character to convert it into a known sign ? Maybe this way could help. Upvote 0
otherwise... How to detect an unknown character to convert it into a known sign ? Maybe this way could help.
klaus Expert Licensed User Longtime User Jul 23, 2021 #4 I am afraid that there is an encoding problem somewhere. This code works: B4X: Copy Private mot As String mot = "séf" Log(mot) mot = mot.Replace("é", "e") Log(mot) You need to give us more information. Where does 'diff�rents' come from? Upvote 0
I am afraid that there is an encoding problem somewhere. This code works: B4X: Copy Private mot As String mot = "séf" Log(mot) mot = mot.Replace("é", "e") Log(mot) You need to give us more information. Where does 'diff�rents' come from?
DALB Active Member Licensed User Jul 23, 2021 #5 One not too bad solution waiting a better one.... the unknown character has an ASCII number which is 65533. Here ASC('the unkwon character') = 65533 I replace it by a special one like '§', and SQLITE accept it for saving my datas. Upvote 0
One not too bad solution waiting a better one.... the unknown character has an ASCII number which is 65533. Here ASC('the unkwon character') = 65533 I replace it by a special one like '§', and SQLITE accept it for saving my datas.
DALB Active Member Licensed User Jul 23, 2021 #6 B4X: Copy Where does 'diff�rents' come from? it's a term coming from a list of words written in french. Upvote 0
B4X: Copy Where does 'diff�rents' come from? it's a term coming from a list of words written in french.
klaus Expert Licensed User Longtime User Jul 23, 2021 #7 Again, where does 'diff�rents' come from? I know that it is french. Where does the list of words come from? Log(Asc("é")) returns 233. Upvote 0
Again, where does 'diff�rents' come from? I know that it is french. Where does the list of words come from? Log(Asc("é")) returns 233.
drgottjr Expert Licensed User Longtime User Jul 24, 2021 #8 "différents" comes from a list which was generated in an 1-byte character set (eg, iso-8859-1, windows 1252, etc). you need to convert it to utf-8. when you take something like "différents" from such a list and use a multi-byte character set (eg, utf-8), you get "diff�rents", the "é" character not being the same in both character sets. replace() and sqlite's insert work just fine if your list is in utf-8. Last edited: Jul 24, 2021 Upvote 0
"différents" comes from a list which was generated in an 1-byte character set (eg, iso-8859-1, windows 1252, etc). you need to convert it to utf-8. when you take something like "différents" from such a list and use a multi-byte character set (eg, utf-8), you get "diff�rents", the "é" character not being the same in both character sets. replace() and sqlite's insert work just fine if your list is in utf-8.
DALB Active Member Licensed User Jul 24, 2021 #9 Klaus, the list is entered manually. I have built a little app to note little things about different subjects. drgottjr Thanks I'll try soon and come back to say what about ! Upvote 0
Klaus, the list is entered manually. I have built a little app to note little things about different subjects. drgottjr Thanks I'll try soon and come back to say what about !
klaus Expert Licensed User Longtime User Jul 24, 2021 #10 As drgottjr already mentioned, it is an encoding problem. the list is entered manually Click to expand... How did you create the list? With a windows application? Then you need to save it with UTF-8 encoding. Upvote 0
As drgottjr already mentioned, it is an encoding problem. the list is entered manually Click to expand... How did you create the list? With a windows application? Then you need to save it with UTF-8 encoding.
DALB Active Member Licensed User Jul 24, 2021 #11 Yes, through windows, because a text file can be imported. So I'll try drgottjr method soon. The app can work like this: A) the text is entered directly in the Edittext zones....no problem B) the texts are in a text file filled with a text software like Word, Text, etc... and imported by email or sms. Upvote 0
Yes, through windows, because a text file can be imported. So I'll try drgottjr method soon. The app can work like this: A) the text is entered directly in the Edittext zones....no problem B) the texts are in a text file filled with a text software like Word, Text, etc... and imported by email or sms.
DALB Active Member Licensed User Jul 24, 2021 #12 With UTF-8, it doesn't work. But I found that there is a 'UTF-8 with nomenclature' (I don't exactly know the difference, I'll see this after), and it works well. So my question in this case is: What is the name of the code UTF-8 with nomenclature in this piece of code ? B4X: Copy Sub Utf2Bytes( s As String ) As Byte() Return s.getbytes("UTF-8") End Sub Sub Bytes2Utf( b() As Byte ) As String Return BytesToString( b, 0, b.Length, "UTF-8" ) End Sub coming from UTF-8 use What do I have to write in the quotes "UTF-8 something", because the files can arrive from many sources ? Upvote 0
With UTF-8, it doesn't work. But I found that there is a 'UTF-8 with nomenclature' (I don't exactly know the difference, I'll see this after), and it works well. So my question in this case is: What is the name of the code UTF-8 with nomenclature in this piece of code ? B4X: Copy Sub Utf2Bytes( s As String ) As Byte() Return s.getbytes("UTF-8") End Sub Sub Bytes2Utf( b() As Byte ) As String Return BytesToString( b, 0, b.Length, "UTF-8" ) End Sub coming from UTF-8 use What do I have to write in the quotes "UTF-8 something", because the files can arrive from many sources ?
agraham Expert Licensed User Longtime User Jul 24, 2021 #13 You need to specify the encoding that the files are saved in. If they come from many different sources they may arrive with many different encodings unless each source of the files has explicitly saved them in UTF-8 encoding. Upvote 0
You need to specify the encoding that the files are saved in. If they come from many different sources they may arrive with many different encodings unless each source of the files has explicitly saved them in UTF-8 encoding.
DALB Active Member Licensed User Jul 25, 2021 #14 O kay thanks for this. I'll change some part of my code to easily import the different files; Upvote 0