WHy does quotes come off as question diamonds?

wheretheidivides

Active Member
Licensed User
Longtime User
I have some text loaded but wherever there are quotes, a diamond shows up with a question mark. It's got to be something simple. I tried changing the font but does the same thing. This is just text in a txt file. I made no changes. I assume it can not figure out what the quotes are so it shows up as a diamond. SO how do I fix?

B4X:
Sub Globals
'===========================================================================================
   Dim MyFont As Typeface
seteverythingup

end sub

Sub SetEverythingUp
'--------------------------------------------
'Instructions
   lblText.Initialize("") ' initialize the Label for the text, without an EventName
   scvText.Panel.AddView(lblText, 0, 0, 90%x, 100%y) ' add the Label on the ScrollView internal Panel
   lblText.TextColor = Colors.White ' set the Label text color

   MyFont = Typeface.LoadFromAssets("times.ttf")
   lblText.Typeface = MyFont
   
   LoadText1 'load the text
    SetText 'set the text
end sub




Sub LoadText1
'---------------------------------------------
'Instructions
    txt = File.GetText(File.DirAssets, "text1.txt") ' load the text file into the string

'---------------------------------------------
End Sub

Sub SetText
'---------------------------------------------
'Instructions
    Dim ht As Float
    
    lblText.Text = txt ' set the text string to the Label text property
       ht = StrUtil.MeasureMultilineTextHeight(lblText, txt) ' measure Label height
    
    scvText.Panel.Height = ht ' set the ScrollView internal Panel height to the measured height
    lblText.Height = ht ' set the Label height to the measured height

    scvText.ScrollPosition = 0 ' set the scroll position to the top of the text
         DoEvents ' needed to execute the previous line
   
'---------------------------------------------
End Sub
 

Attachments

  • a.jpg
    a.jpg
    46.6 KB · Views: 223
Last edited:

wheretheidivides

Active Member
Licensed User
Longtime User
Can you upload the text file?

This is just a text file I made with windows 8 notepad viewing on my Samsung galaxy S phone. It looks fine on windows 8. I changed the font to times new roman to see if that'd fix it. It didn't.
 

Attachments

  • text1.txt
    16.4 KB · Views: 182
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
It has to do with the chosen encoding. It will be fixed, if you choose utf-8 instead of the one you currently use.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The text file is encoded with an 8-bit encoding which will probably the default for the location of your Windows installation. File.GetText assumes the encoding is UTF-8 and the byte values for the two quote characters are not valid UTF-8 code points. You can resave the file in Notepad as UTF-8 but File.GetText may return the Byte Order Marker that Notepad places at the start of a UTF-8 encoded file in which case you will need to strip it off.
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
Thanks. I knew it was something simple like that. In notepad I 'saved as' and then there was a area for encoding. I just changed it.
 
Upvote 0
Top