Android Question CSV to SQlite accented characters

Discussion in 'Android Questions' started by luciano deri, Aug 30, 2016.

  1. luciano deri

    luciano deri Active Member Licensed User

    Hello everybody. I import some csv data into a sqlite db with this code.
    Code:
    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 (3As 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.
     
  2. DonManfred

    DonManfred Expert Licensed User

    make sure the file is saved with utf-8 charset
     
  3. luciano deri

    luciano deri Active Member Licensed User

    No, the files are saved with the Windows character set. There is a mapping between the two decoding systems to solve this problem?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Use TextReader.Initialize2 and pass Windows-1250 as the charset.
     
    DonManfred likes this.
  5. luciano deri

    luciano deri Active Member Licensed User

    No, now char "ì" became "ĕ"
     
  6. DonManfred

    DonManfred Expert Licensed User

    Check the charset of the file with notepad++ (for ex)
    Use the correct charset in initialize2 then
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice