Downloadfile and text files

N1c0_ds

Active Member
Licensed User
I tried using downloadfile to retrieve CSV and text files and they are rendered unusable when downloaded to the device.

They turn from this:
Hello
This is a test

To this:
Hello[]This is a test

The line breaks get replaced with rectangle characters (unknown character) and it renders the file useless.

Is there a fix to this?
 

Cableguy

Expert
Licensed User
Longtime User
You could search the returned string and replace all the "[]" by "crlf"...

Something like
newstring=StrReplace (oldstring,"[]","crlf")
 

agraham

Expert
Licensed User
Longtime User
Do you mean this http://www.b4x.com/forum/questions-help-needed/2157-download-files.html

How are you displaying the file when you are seeing those rectangular characters? Rectangular boxes are unprintable characters. You can check what they are by
B4X:
nstr = ""
For i = 0 to Strlen(Str) - 1
  nstr = nstr & Asc(StrAt(Str, i) & " "
Next
Msgbox(nstr)
A line break should be 13 (Cr) followed by 10 (Lf)
 

N1c0_ds

Active Member
Licensed User
I found the solution!

The unknown character is chr(10). You have to replace it with chr(13) & chr(10) usung StrReplace.

Thanks for your help!
 
Top