ThRuST Well-Known Member Licensed User Longtime User Dec 16, 2018 #1 When loading a textfile into textarea the © sign (ALT+0169) does not display correctly when the textfile is loaded into textarea. I have tried different fonts but that did not solve the problem. Should UTF8 format be used when loading a textfile correctly? This is what I tried Code: Copy Sub ReadText Dim Te As String Te = File.ReadString(ApplicationPath, "Textfile.txt") Te.GetBytes("UTF8") TextArea.Text = Te End Sub
When loading a textfile into textarea the © sign (ALT+0169) does not display correctly when the textfile is loaded into textarea. I have tried different fonts but that did not solve the problem. Should UTF8 format be used when loading a textfile correctly? This is what I tried Code: Copy Sub ReadText Dim Te As String Te = File.ReadString(ApplicationPath, "Textfile.txt") Te.GetBytes("UTF8") TextArea.Text = Te End Sub
Erel B4X founder Staff member Licensed User Longtime User Dec 16, 2018 #2 1. Why do you dim the variable on one line and only set it on the second line? 2. The third line (TE.GetBytes) doesn't do anything useful. Code: Copy TextArea.Text = File.ReadString(ApplicationPath, "Textfile.txt") File.ReadString expects UTF8 encoding. There are two possible causes: 1. The font doesn't include this sign (unlikely). 2. The text file encoding is not UTF8. Upvote 0
1. Why do you dim the variable on one line and only set it on the second line? 2. The third line (TE.GetBytes) doesn't do anything useful. Code: Copy TextArea.Text = File.ReadString(ApplicationPath, "Textfile.txt") File.ReadString expects UTF8 encoding. There are two possible causes: 1. The font doesn't include this sign (unlikely). 2. The text file encoding is not UTF8.
xulihang Well-Known Member Licensed User Longtime User Dec 16, 2018 #3 I use icu4j to detect encoding and convert to utf-8. There is a b4j wrapper: https://www.b4x.com/android/forum/threads/icub4j-detect-character-encoding-formats.65404/#content Upvote 0
I use icu4j to detect encoding and convert to utf-8. There is a b4j wrapper: https://www.b4x.com/android/forum/threads/icub4j-detect-character-encoding-formats.65404/#content
ThRuST Well-Known Member Licensed User Longtime User Dec 16, 2018 #4 Here's a small source code example to support my question. Modify it and post your working solution. Try hold ALT and type 0169 to get the © sign in the textarea. As you can see it shows, but not from the loaded textfile. It was saved as a textfile in Notepad on Windows 7. Click to expand... Attachments ReadString01.zip ReadString01.zip 15.1 KB · Views: 497 Last edited: Dec 16, 2018 Upvote 0
Here's a small source code example to support my question. Modify it and post your working solution. Try hold ALT and type 0169 to get the © sign in the textarea. As you can see it shows, but not from the loaded textfile. It was saved as a textfile in Notepad on Windows 7. Click to expand...
K keirS Well-Known Member Licensed User Longtime User Dec 16, 2018 #5 My solution. Open myText.txt in Notepad. Select File/Save As and change the encoding from ANSI to UTF8. Upvote 0
My solution. Open myText.txt in Notepad. Select File/Save As and change the encoding from ANSI to UTF8.
ThRuST Well-Known Member Licensed User Longtime User Dec 16, 2018 #6 I noticed that I saved the textfile with Wordpad as default, which have different options when saving files. Thanks for bringing some clarity in this all of you. Upvote 0
I noticed that I saved the textfile with Wordpad as default, which have different options when saving files. Thanks for bringing some clarity in this all of you.
ThRuST Well-Known Member Licensed User Longtime User Dec 16, 2018 #7 Here's a page that explains the differences between ANSI and UTF-8. Go here Upvote 0
ThRuST Well-Known Member Licensed User Longtime User Dec 17, 2018 #10 Here is a link to Notepad++ Get it here Upvote 0