Http download .csv UTF-8

Merlot2309

Active Member
Licensed User
Longtime User
Hello,

Used the HTTPUtils example to download a .csv file.
It functions eventhough I only need 1 file download ......

But I can´t get it encoded as UTF-8 by code.
I´m also not sure if the encoding has to be done in the Service part or in Main.

Thanks in advance.

Helen.
 

Attachments

  • HTTPUtils.zip
    8.3 KB · Views: 272

Merlot2309

Active Member
Licensed User
Longtime User
Hi,

The website source shows meta with charset UTF-8

The csv file has 2 diamonds with ? as the first 2 characters.
Tried to skip them with substring(2), which has no effect what so ever.

Thanks in advance.

Helen.
 
Upvote 0

robotop

Member
Licensed User
Longtime User
Hello Helen, may be you can find something useful in this php help page:
PHP: utf8_encode - Manual
BTW, the first 4 bytes of the file you're downloading, seems to be 0xFF 0xFE 0x22 0x00.
ciao
 
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Hi,

Thank you both for the info and links, I have to do some reading and it has to sink in.

FF FE indeed is the BOM and the signs ÿþ do appear, depending of the reader that I use on my device.
On the PC they appear as 2 beautiful little diamonds, when opened in Notepad.

Am I thinking in the right direction that I have to use a replace?? as mentioned in Robotops link.

I use ES File Explorer from the Market, you can choose from 4 Editors/Readers and I like the design, ha, ha.
Some readers show UTF-8 as the standard setting.
Honoustly I can´t stand it because I know it must be possible to load the file into a database.

Ciao (stolen from Robotop),

Helen.

Ps. BOM is Dutch for bomb. I promise I will explode when I get this runnning ;)
 
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Hi,

This is the code part that does what it´s suppose to do.

B4X:
Sub JobDone (Job As String)

   HandleCsv
   If HttpUtils.IsSuccess(csvUrl) Then
      ceesv = HttpUtils.GetString(csvUrl)
   End If
   HttpUtils.Complete = False 
   ceesv = ceesv.SubString(412)
   File.WriteString(File.DirRootExternal, "vogeltjes.csv", ceesv)

End Sub

I skipped the column names completely (double column names, names with spaces ..........).

That's it for now. Have to start with some new sql commands, so maybe, maybe I have to alter the code sample above.

Thanks for the help!

Helen.
 
Upvote 0
Top