asales Expert Licensed User Longtime User Mar 4, 2022 #1 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: Copy 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 15.6 KB · Views: 550 breakline2.jpg 9.3 KB · Views: 541
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: Copy 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.
drgottjr Expert Licensed User Longtime User Mar 4, 2022 #2 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
try a different charset. maybe iso-8859-1. maybe windows-1252. depends on where text came from and how it was encoded originally
William Lancee Well-Known Member Licensed User Longtime User Mar 4, 2022 #3 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
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.
asales Expert Licensed User Longtime User Mar 5, 2022 #4 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: Copy msg.Replace(Chr(13), "") Thanks @William Lancee for the tip. Upvote 0
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: Copy msg.Replace(Chr(13), "") Thanks @William Lancee for the tip.