ReadList

magarcan

Active Member
Licensed User
Longtime User
I'm using this code for reading a file:
B4X:
Dim List1 As List
List1 = File.ReadList(File.DirDefaultExternal, "1.txt")
For i = 0 to List1.Size - 1
   Log(List1.Get(i))
Next

And this one, for writing:
B4X:
Dim List1 As List
List1 = File.ReadList(File.DirDefaultExternal, "1.txt")

I've a problem with codification because some Latin characters lite: á, é ,í... apears like this �, How can I solve this??

Thanks!!
 

magarcan

Active Member
Licensed User
Longtime User
The code for writing is wrong, but I am sure you just posted the wrong code.
You are right. This is the code:
B4X:
File.WriteList (File.DirDefaultExternal, Archivo & ".htm", List1)

Any idea about my problem with encoding?
 
Upvote 0

magarcan

Active Member
Licensed User
Longtime User
The problem is most probably somewhere else. Both WriteList and ReadList use UTF8 encoding which supports all Unicode characters.
File I'm reading looks like this:
B4X:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE data PUBLIC "-//ASO//VE 2011 01" "http://www.lavuelta.com/11/xml/VE2011-01.dtd">
<data type="standings" race="VE" year="2011" stage="0100">
<standings type="ITG" oficiosa="0">
<rank position="1" number="103"/>
</standings>
</data>

Could be here the problem?
 
Upvote 0

magarcan

Active Member
Licensed User
Longtime User
Where does your file come from ?
The problem is that your file is encoded with iso-8859-1 and not with URF-8 !
That means that your file was not saved in B4A but somewhere with Windows.

Best regards.
File is an .XML that is downloaded from Internet...
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
File is an .XML that is downloaded from Internet...

Strange characters are due to different encoding. Now, probably there is something for this case, but if there isn't, you have to create a subroutine for converting from one encoding to the other.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…