Android Question I create a Chinese text file news.txt and let B4A to read it. It can't be displayed in Chinese.

AndyChang

Member
Licensed User
I write a simple test program (as attached Zip file) to test the file input.

tr.Initialize(File.OpenInput(File.DirAssets,"news.txt"))
line = tr.ReadLine
Listview1.AddSingleLine(line)

The above three statements are the main statements
It works, but can't be display in Chinese as the screen picture shown.(pls reference the attached png file)
If use Label display like lblmsg2.Text = " Read file Finished 完成讀檔程序", the Chinese can be display OK.
Please teach me how to solve the problem.
Thanks a lot.
Andy
 

Attachments

  • readAndDisplayChineseText.zip
    8.3 KB · Views: 206
  • unreadable.png
    120.6 KB · Views: 203
  • ChineseTextFile.png
    109.4 KB · Views: 216

AndyChang

Member
Licensed User
Dear Sir Manfred
It works nice as the attached picture of the result.
Do you change something about the news.txt?
I type the news file by using the Window's notebook function
Please teach me how to change the characteristic of the txt file.
By the way, May we narrow down the gap between each line of the listview.
Thank you for your kindness to help me.
Andy
 

Attachments

  • the screen result.png
    73.2 KB · Views: 179
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I type the news file by using the Window's notebook function
do not use windows notepad!! It is the baddest Texteditor known.

Download Notepad++ https://notepad-plus-plus.org/
When writing a file you should ensure that you are saving it with UTF8-Encoding.

Do you change something about the news.txt?
Yes. I loaded it in notepad++, changed the encoding of the file to utf8 and saved the file. then i run your app again.
 
Upvote 0

AndyChang

Member
Licensed User
Dear Mr. Manfred
I found the way to set the distance between the lines in listview. I have solved my confuse, thank you.
ListView1.SingleLineLayout.ItemHeight = 5%y
Andy
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…