Android Question Unicode characters not appearing in EditText

Asit

Member
Licensed User
Hi,
I am working on a suite of multi-lingual dictionary/thesaurus apps. I have used Android/Java to develop my previous apps but now am trying to develop using B4A.

I made a simple app that takes an English word in an EditText field. When "Search" button is tapped, it shows Sanskrit translations in another EditText field. I am not using SQL to store data. Instead, I use a Unicode text file having Sanskrit, English words with newline delimiter. It is a CSV file to be honest, having thousands of words. One more thing, I have several Sanskrit terms for a single English word so the results show up like this with / delimiter:

Some Sanskrit term / Some Sanskrit term /Some Sanskrit term /Some Sanskrit term

The problem is that the Sanskrit terms do not even show up and the result I get is like:

/ / - / / / / /

I have tried changing font to SANS-SERIF and SERIF in the "Visual Designer" but the only difference I can see that when setting to SERIF it shows rectangular block characters instead of spaces. Would like to add that I have tested the code on emulator only and not on a real device as my testing tab is gone for repair and I don't normally test on my phone.

Please help me to find a solution to this problem. My thanks in advance for any assistance!

The relevant code below:
B4X:
'SEARCH ENGLISH TERM IN THE DICTIONARY LIST
Sub searchInDictES (searchTerm As String)
    Dim eng, sans, sansResult As String
    Dim listLen As Int
    
    listLen = lstDictEng.Size    'LIST SIZE
    sansResult = ""                    'EMPTY RESULT VARIABLE
    
    Try
        edtResults.Text = "Searching.. Please wait.."
        pause(200)
        
        For i = 0 To listLen-1
            eng = lstDictEng.Get(i)
            
            If eng.ToLowerCase = searchTerm.ToLowerCase Then
                sans = lstDictSans.Get(i)
                sansResult = sansResult & " / " & sans
                
            End If
            
        Next
        edtResults.Text = sansResult 'Print in the result window..
        
    Catch
        msgL(LastException) 'DEBUG
        
    End Try
    
End Sub

Screenshots below (it is pre-alpha so sorry for plain black bg lol):
Screenshot_1547823870.png
Screenshot_1547823923.png
 

DonManfred

Expert
Licensed User
Longtime User
I use a Unicode text file having Sanskrit, English words with newline delimiter.
it is encoded in UTF8? If not then you need to adapt your code to use the right encoding.
B4A is using UTF8

Upload a sample text file you are using.

Ideally including a sample project (File Export as zip)
 
Upvote 0

Asit

Member
Licensed User
Hi Don,
Thanks for a swift response! The vocab list is a massive file so I am using a mini version of it ("words2.txt") for testing. Let me upload the project here for your review.
 

Attachments

  • SansEngDictionary.zip
    11.1 KB · Views: 275
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
my first sigth of the textfile using notepad++ is OK. The signs are visible and the file is UTF8 encoded.

after i checked the values loaded. They seems to work ok.

I then put some logs

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
अक्षत,corns
English: corns
Sanskrit: अक्षत
त्रियव,corns
English: corns
Sanskrit: त्रियव
अङ्गुल,corns
English: corns
Sanskrit: अङ्गुल
यवक्षार,corns
English: corns
Sanskrit: यवक्षार
प्रपुट,cornucopia
English: cornucopia
Sanskrit: प्रपुट
उपप्रमेय,corollary
English: corollary
Sanskrit: उपप्रमेय
उपनिर्मेय,corollary
English: corollary
Sanskrit: उपनिर्मेय
उपसाध्य,corollary
English: corollary
Sanskrit: उपसाध्य
मुकुट,corona
English: corona
Sanskrit: मुकुट
अभिषेक,corona
English: corona
Sanskrit: अभिषेक
राज्याभिषेक,corona
English: corona
Sanskrit: राज्याभिषेक
वलय-रोहिणी,corona
English: corona
Sanskrit: वलय-रोहिणी
ओष्ठवलय-रोहिणी,corona
English: corona
Sanskrit: ओष्ठवलय-रोहिणी
आमाशयवलय-रोहिणी,corona
English: corona
Sanskrit: आमाशयवलय-रोहिणी
ह्रद्रोहिणी,corona
English: corona
Sanskrit: ह्रद्रोहिणी
वलिकाय-वलय,corona
English: corona
Sanskrit: वलिकाय-वलय
ककुत्-प्रवर्ध,corona
English: corona
Sanskrit: ककुत्-प्रवर्ध
हृदयव्याधि,corona
English: corona
Sanskrit: हृदयव्याधि
महाभिषेक,corona
English: corona
Sanskrit: महाभिषेक
अभिषेकशाला,corona
English: corona
Sanskrit: अभिषेकशाला
स्कन्ध,corona
English: corona
Sanskrit: स्कन्ध
राजसूय,corona
English: corona
Sanskrit: राजसूय
वलय-रोहिणी,coronary
English: coronary
Sanskrit: वलय-रोहिणी
ओष्ठवलय-रोहिणी,coronary
English: coronary
Sanskrit: ओष्ठवलय-रोहिणी
आमाशयवलय-रोहिणी,coronary
English: coronary
Sanskrit: आमाशयवलय-रोहिणी
ह्रद्रोहिणी,coronary
English: coronary
Sanskrit: ह्रद्रोहिणी
ककुत्-प्रवर्ध,coronary
English: coronary
Sanskrit: ककुत्-प्रवर्ध
हृदयव्याधि,coronary
English: coronary
Sanskrit: हृदयव्याधि
अभिषेक,coronation
English: coronation
Sanskrit: अभिषेक
राज्याभिषेक,coronation
English: coronation
Sanskrit: राज्याभिषेक
महाभिषेक,coronation
English: coronation
Sanskrit: महाभिषेक
अभिषेकशाला,coronation
English: coronation
Sanskrit: अभिषेकशाला
स्कन्ध,coronation
English: coronation
Sanskrit: स्कन्ध
राजसूय,coronation
English: coronation
Sanskrit: राजसूय
निगम,corpora
English: corpora
Sanskrit: निगम
जीवन रक्षा संस्था,corpora
English: corpora
Sanskrit: जीवन रक्षा संस्था
समामेलित,corpora
English: corpora
Sanskrit: समामेलित
समूह,corpora
English: corpora
Sanskrit: समूह
स्नेह-काय,corpora
English: corpora
Sanskrit: स्नेह-काय
निगम-कर,corpora
English: corpora
Sanskrit: निगम-कर
शरीरदण्ड,corpora
English: corpora
Sanskrit: शरीरदण्ड
ग्रामसङ्घ,corpora
English: corpora
Sanskrit: ग्रामसङ्घ
महागण,corpora
English: corpora
Sanskrit: महागण
गणप,corpora
English: corpora
Sanskrit: गणप
गणपुङ्गव,corpora
English: corpora
Sanskrit: गणपुङ्गव
गणद्रव्य,corpora
English: corpora
Sanskrit: गणद्रव्य
वध्य,corpora
English: corpora
Sanskrit: वध्य
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
searchInDictES(corona)
Loop. english = corns
Loop. english = corns
Loop. english = corns
Loop. english = corns
Loop. english = cornucopia
Loop. english = corollary
Loop. english = corollary
Loop. english = corollary
Loop. english = corona
Match found sanskrit = मुकुट
Loop. english = corona
Match found sanskrit = अभिषेक
Loop. english = corona
Match found sanskrit = राज्याभिषेक
Loop. english = corona
Match found sanskrit = वलय-रोहिणी
Loop. english = corona
Match found sanskrit = ओष्ठवलय-रोहिणी
Loop. english = corona
Match found sanskrit = आमाशयवलय-रोहिणी
Loop. english = corona
Match found sanskrit = ह्रद्रोहिणी
Loop. english = corona
Match found sanskrit = वलिकाय-वलय
Loop. english = corona
Match found sanskrit = ककुत्-प्रवर्ध
Loop. english = corona
Match found sanskrit = हृदयव्याधि
Loop. english = corona
Match found sanskrit = महाभिषेक
Loop. english = corona
Match found sanskrit = अभिषेकशाला
Loop. english = corona
Match found sanskrit = स्कन्ध
Loop. english = corona
Match found sanskrit = राजसूय
Loop. english = coronary
Loop. english = coronary
Loop. english = coronary
Loop. english = coronary
Loop. english = coronary
Loop. english = coronary
Loop. english = coronation
Loop. english = coronation
Loop. english = coronation
Loop. english = coronation
Loop. english = coronation
Loop. english = coronation
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora
Loop. english = corpora

So it does work basically. At least for me?
 
Upvote 0

Asit

Member
Licensed User
I guess you are getting that result in both logs and a run. In that case something might be wrong with my emulator. At work right now, so when I get back home today I will try to run on a device.
Thanks again for checking the code! I will reaport back my findings later today. Cheers!
 
Upvote 0

Asit

Member
Licensed User
Hi Don, sorry for my delayed response. Turns out it was an emulator issue, for backward compatibility I was using Android 4.4.2 version for my emulator. Yesterday I made a new one with Android 7 and tested on it with correct results. Also, it was good on my device as well. Not sure what lacked in the previous emulator :confused: probably fonts (??) but no worries. Thanks again for your prompt assistance, really appreciate it! :)
 
Upvote 0
Top