Android Question [solved] how to use the List.Sort ??? (issue with utf-8 byte order mark from notepad editor)

MarkusR

Well-Known Member
Licensed User
Longtime User
i have a textfile in utf-8 and this code but the list is not sorted. (7.80)
i put a A at top of the file and a Z an the end.

B4X:
    Dim problems As List = File.ReadList(File.DirAssets,"problems.txt")
    problems.Sort(True)

    Dim i As Int
    For i = 0 To problems.Size-1
        Log(problems.Get(i))
    Next
 

Attachments

  • Snap_2018.03.21_17h34m13s_001.png
    Snap_2018.03.21_17h34m13s_001.png
    35.4 KB · Views: 394

MarkusR

Well-Known Member
Licensed User
Longtime User
it seems there is a sort bug with utf-8
if me using the file in Ansi the umlauts [äöü] are wrong displayed in app.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
interesting,thanks for this hint.
but me thought b4a based on utf-8, the first char is just A-Z or its better to use unicode text files?
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
Can you upload the text file? Is it encoded with UTF 8?
here it is, it is a list of IT issues i saved with notepad in utf-8.
 

Attachments

  • problems.txt
    349 bytes · Views: 390
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
thank you, i put an empty row first. we faced this BOM issue also in batch files not long ago.
i watched all of your videos, i will watch again :) ... its part of videos "Strings"
 
Last edited:
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
Doesn´t change anything if you still uses BOM. The solution is NOT TO USE BOM inside the File.
How are you creating this file? Programatically?

correct, at least with a dummy line my first entry with A is at top in my sort :)
it was just a manual input in editor. i will make a feature request at ms.
i can also use notepadd++ where i make this app.
maybe i will put my lists into a sqllite db later on.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
As written by Erel you should NEVER use Editor. Use Notepad++ instead.
i avoid generally downloading apps from web that use admin permissions at install. and without permissions they have my user permissions.
why i can not open/edit this textfile in the ide editor?
if you drag a textfile on this ide link it got the filename and its ignored. the open menü not support .txt
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0
Top