Android Question Text files with CRLF

AlpVir

Well-Known Member
Licensed User
Longtime User
I can not create text files that are readable by other programs such as Notepad (Windows).
B4X:
Dim TW As TextWriter
TW.Initialize(File.OpenOutput(File.DirRootExternal,NomeFileLog,False))
TW.Writeline ("OziExplorer Track Point File Version 2.1")
TW.Writeline ("WGS 84")
TW.Writeline ("Altitude Is in Feet")
TW.Close
B4X:
'-------------------------  CRLF
Dim TW As TextWriter
TW.Initialize(File.OpenOutput(File.DirRootExternal,NomeFileLog,False))
TW.Write ("OziExplorer Track Point File Version 2.1"&CRLF)
TW.Write ("WGS 84"&CRLF)
TW.Write ("Altitude Is in Feet"&CRLF)
TW.Close
B4X:
'------------------------- CR
Dim TW As TextWriter
dim CR as string
CR=chr(13)
TW.Initialize(File.OpenOutput(File.DirRootExternal,NomeFileLog,False))
TW.write ("OziExplorer Track Point File Version 2.1"&CR)
TW.Write ("WGS 84"&CR)
TW.Write ("Altitude Is in Feet"&CR)
TW.Close

I also tried to initialize TextWriter with a Encoding (Windows-1252 e other)
B4X:
TW.Initialize2 (File.OpenOutput (File.DirRootExternal,NomeFileLog, False), "Windows-1252")
The various lines are ALWAYS separated by an LF [chr (10), hexadecimal A] and not by a CRLF
How can we succeed ?
Thanks for the attention
 

DonManfred

Expert
Licensed User
Longtime User
CRLF is just 10 in b4x.... write chr(10)+chr(13) instead
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
In this way you see in correct mode both:
B4X:
Dim TW As TextWriter
    TW.Initialize(File.OpenOutput(File.DirRootExternal,"test_caratteri3b.txt",False))
    TW.Write ("OziExplorer Track Point File Version 2.1"&Chr(0x0d)&Chr(0x0a))
    TW.Write ("WGS 84"&Chr(0x0d)&Chr(0x0a))
    TW.Write ("Altitude Is in Feet"&Chr(0x0d)&Chr(0x0a))
    TW.Close

upload_2017-7-11_7-44-52.png
 

Attachments

  • upload_2017-7-11_7-43-56.png
    upload_2017-7-11_7-43-56.png
    36.7 KB · Views: 433
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
The final purpose of my app is not to create and display a text file in notepad. It is (fully achieved, thanks!) to create and display a text file in commercial software (CompeGPS Land) and also on a web page (with ASP, VBScript and Javascript scripts).
Thanks again to everyone!
 
Upvote 0
Top