Android Question Letters formatting (file format UTF /ANSI )?

hookshy

Well-Known Member
Licensed User
Longtime User
I have some problems with testing if the input word contains a letter .
The code below adds words to a list upon a letter identification criteria like this :
I promt user: Enter a word with the letter c
Test if the new input word contains letter c and save the word else prompt error.

I have a list of letter saved in a file named listac formatted UTF-8 that contains letters :B,C,D,F,G,H,J,L,M,N,P,R,S,Ş,T,Ţ,V,Z
file here: https://www.dropbox.com/s/pdbxanfzu1unq9r/listac.txt

I use format UTF-8 to be able to display diacritics like Ş Ţ,


Question or problem: The code works great for all letters except B !
What is with this letter that the code does not accept it ? or with me .
In log after entering B it shows correctly but the loop condition does not see that the letter is actuall B
and displays the message box please enter word with letter B


If I use format ANSI then the letter B works as well but I can not display Ş Ţ so it does not help me much

B JUST BEAT ME THIS TIME . :)
Thanks for helping



B4X:
Sub alit_click

Dim alit As Button
alit=Sender
Dim row As Int
row=alit.tag
grow=row


'If row<>0 Then

Dim position As Int
position=row
Dim value As String
value=tokenlist.Get(row)

sincronizare(position ,value)



Dim xtoc As String
xtoc=listaclist.Get(row)

Dim newlit As EditText
newlit.Initialize("")

add.AddView(newlit,10dip,10dip,320dip,50dip)
add.Show("New word with letter: "&xtoc,"Save","Cancel","",Null) 'CUSTOM DIALOG SHOW

If add.Response=-1 Then

    Log("newlit.text"&newlit.Text.ToUpperCase)
 
    If newlit.Text.ToUpperCase.Contains(xtoc) Then
     
        lista.add(newlit.Text.ToUpperCase) 'saves the new word to current list
        save_word(position) 'save routine like: File.WriteList(File.DirDefaultExternal,"b.txt",lista)
     
        afisare_lit ' shows words list in scrolview
        ToastMessageShow("New letter added !  "&newlit.Text,True)
 
    Else
        Msgbox("Letter must contain: "&xtoc,"Notification")
    End If

End If

'Else
'Msgbox("This lettter is not availlable ,please try another one",Null)
'
'End If


End Sub
 
Last edited:

hookshy

Well-Known Member
Licensed User
Longtime User
I tryed and it shows B
I guess it is something with the format

I inserted the code below when reading another file ... because I had problems with first word in the file so I guess it is the same problem with the
letters files where B is the first entry .

lista is a list of words from a file format UTF-8

B4X:
If level=0 Then
word=lista.Get(level)
word=cuvant.SubString(1) ' fixed bug
Else
word=lista.Get(level)
End If
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
It is solved with the code below but it would be interesting to know who it works and how android reads the UTF-8
file format.
I use this statement to read basic list from file
listaclist=File.ReadList(File.DirAssets,"listac.txt")


If I will find out I will share but I do not now much about how android read file formats and how IDE is involved in reading . If this is an issue that I do not now how to control .
thanks you for your help

B4X:
If row=0 Then
xtoc=xtoc.SubString(1)
End If
 
Upvote 0
Top