Android Tutorial PC-ANSI encoding on B4A ...

Hi,

normaly B4A use UTF8 encoding, but can create files in ANSI too, but be carefull !
Windows an a Western PC use ANSI codepage 1252, this is in B4A "WINDOWS-1252".
Mostly the encoding "ISO-8859-1" ist used, but this does not support all chars:
€ is only valid in "ISO-8859-15" - wich does not work in B4A, "WINDOWS-1252" do !

If you write text files for Windows PCs, they need CRLF (chr(13)+chr(10)), while CRLF on Android is only chr(10) like other UNIX / Linux systems too, so you have to build the text file like this (here a CSV file):

B4X:
Dim CSV As TextWriter
Dim sAnsi = "Windows-1252"  As String
Dim sWinCRLF = Chr(13) & Chr(10)  As String  ' Windows CRLF
CSV.Initialize2( File.OpenOutput( sP, sF, False ), sAnsi )
CSV.Write(SHeaderLine & sWinCRLF )
...
CSV.Write(sDataLine & sWinCRLF )
...
CSV.Close
 
Top