I want to upload a CSV file via FTP, so far, no problem:
The pb is the target, a SAP integration system, which wants pure UTF-8 encoded file, and it seems (accordingly to the SAP IT people), I send a UTF-8 without BOM file.
He expects a pure UTF-8 CSV file, and not a UTF-8 Without BOM file, like Notepad++ shows...
I can say I'm pretty confused, cause I thaught StringUtils SaveSCV2, in B4J, was supposed to create a UTF-8 file...
So I'm lost with those UTF-8, UTF-8 Without BOM...
Standard UTF 8 text files do not include the BOM header. B4J (as well as B4A and B4i) will not add this header.
You can use this code to create a text file that starts with this header:
B4X:
Dim out As OutputStream = File.OpenOutput(...)
out.WriteBytes(Array As Byte(0xEF,0xBB,0xBF), 0, 3)
Dim tw As TextWriter
tw.Initialize(out)
'write the text with tw
tw.Close
Public Sub Export_(dir_ As String, File_ As String, content As String)
Dim rows As StringBuilder
rows.Initialize
Dim bytes() As Byte = Array As Byte(239,187,191)
rows.Append(BytesToString(bytes,0,3,"UTF8"))
rows.Append(content & CRLF )
File.writestring(dir_, File_, rows.tostring)
End Sub