Android Question Getbytes () text encoding

rabbit2

Member
Hello how to deal with it?

Dim a As String ''
Dim b As String
a = "ŚĆłł" '<---- are Polish characters of the alphabet
b = a.GetBytes ("Unicode")
File.WriteString as - >>> b .txt
b.txt ----> send to FTP as a .txt file

the downloaded and displayed b.txt file on another computer looks like this "iÄ"

How to change the b.txt encoding before uploading to ftp

Sorry for the way I wrote it, but it's for illustration.
 

rabbit2

Member
B4X:
Dim text1 As String
   text1="ŻŹŚĆ"
    File.WriteString(foldertxt,"sample.txt",text1 )
        FTP.Initialize("FTP", "**********", 21, "*******", "********")
        FTP.PassiveMode=True
    FTP.UploadFile(foldertxt, "sample.txt", False, folder)
 FTP.Close

Downloaded sample.txt and displayed in a browser on each computer, for example, is displayed incorrectly.
To be properly displayed it needs UTF8 encoding from the BOM.
UTF8 without a BOM displays incorrectly.

Can someone easily explain it to me how to convert from UTF8 to UTF8 with BOM?
I'm a beginner, so forgive me
 
Upvote 0

rabbit2

Member
[CODE = b4x]
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[/CODE]

i used it. It works :)
 
Upvote 0
Top