R rabbit2 Member Jan 31, 2021 #1 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.
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.
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2021 #2 Please use [code]code here...[/code] tags when posting code. Use UTF8 not Unicode. Upvote 0
R rabbit2 Member Jan 31, 2021 #3 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
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
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2021 #4 B4X will never add BOM. UTF8 = UTF8 without BOM. Upvote 0
R rabbit2 Member Jan 31, 2021 #5 [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
[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