Android Question CSV to SQlite accented characters

luciano deri

Active Member
Licensed User
Longtime User
Hello everybody. I import some csv data into a sqlite db with this code.
B4X:
sub readcsv
    Dim Reader As TextReader
               Reader.Initialize(File.OpenInput(Main.PthIO, nomefilelocale))
               Dim line As String
            line = Reader.ReadLine
            'nella prima linea c'è l'intestazione
            line = Reader.ReadLine
            Do While line <> Null
                DoEvents
                  Dim sColumn() As String
                sColumn = Regex.Split(";", line)
                ImportCSV(sColumn)
                line = Reader.ReadLine
              Loop
                               
            DoEvents
            Main.dbSql.TransactionSuccessful
            Main.dbSql.EndTransaction
            ProgressDialogHide
end sub
Sub ImportCsv(sColumn()As String)
    Dim AppColumn (3) As String
    strquery ="INSERT or REPLACE INTO tabella(col1,  col2, col3)"
    strquery = strquery  & " VALUES      ('" & AppColumn(0) & "','"& AppColumn(1) & "','"& AppColumn(2) & "')"
     Log(strquery)
    Main.dbSql.ExecNonQuery(strquery)
End Sub

If in a AppColumn is a accented character inside db i find a �.
How can import all correct characters?
Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
make sure the file is saved with utf-8 charset
 
Upvote 0

luciano deri

Active Member
Licensed User
Longtime User
No, the files are saved with the Windows character set. There is a mapping between the two decoding systems to solve this problem?
 
Upvote 0
Top