Android Question [Solved] Break line with strange character in SQLite

asales

Expert
Licensed User
Longtime User
I read a text field from an sqlite database.
When I show it in a label, I get this stranges characters in the end of the line, when ir has a line break.
If I read the content and show in the logs or in an edittext, there is no strange character. Only When I show in the label.
The field is an text type. I try to read with this codes without success:
B4X:
rs.GetString("message")

Dim b() As Byte = rs.GetBlob("message")
msg = BytesToString(b, 0, b.Length, "utf8")
What could be the problem and how can I fix it?

Thanks in advance for any tip.
 

Attachments

  • breakline1.jpg
    breakline1.jpg
    15.6 KB · Views: 113
  • breakline2.jpg
    breakline2.jpg
    9.3 KB · Views: 122

drgottjr

Expert
Licensed User
Longtime User
try a different charset. maybe iso-8859-1. maybe windows-1252. depends on where text came from and how it was encoded originally
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
In B4X the end of line marker constant is CRLF which is actually only one character Line Feed (ASCII 10)
The blob has both CR (ASCII 13) and LF (ASCII 10). The Log adapts to either but the label does not.

Just remove it with .replace or try a different charset in BytesToString as @drgottjr said a moment ago.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Thanks for the answers.
- I tried to change the charset (to iso-8859-1 and windows-1252) without success.
- The problem was solved with this:
B4X:
msg.Replace(Chr(13), "")
Thanks @William Lancee for the tip.
 
Upvote 0
Top