B4J Question Replace &qout with "

MichalK73

Well-Known Member
Licensed User
Longtime User
Hello.
I pull the text from the page (httpjob) and the titles I put into the UTF-8 database.
However, I get something like this:
" RADOMSKO KNOWN AND UNKNOWN "
instead
"RADOMSKO KNOWN AND UNKNOWN"
How do you replace &qout with char " to correctly save to the database?
 

stevel05

Expert
Licensed User
Longtime User
If that is your only problem you could replace them directly :
B4X:
Dim Test As String = "" RADOMSKO KNOWN AND UNKNOWN ""

Dim Result As String = Result.Replace($"" "$,$"""$).Replace($" ""$,$"""$)
    Log(Result)

If there are other html codes you need to remove then it would be more efficient to use a library such as jsoup to remove them all at once:
B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region
#AdditionalJar: jsoup-1.11.2
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
    
    Dim JS As JavaObject
    JS.InitializeStatic("org.jsoup.parser.Parser")
    
    Dim Test As String = "" RADOMSKO KNOWN AND UNKNOWN ""
    
    Dim Result As String = JS.RunMethod("unescapeEntities",Array(Test,True))
    Result = Result.Replace($"" "$,$"""$).Replace($" ""$,$"""$)
    Log(Result)
    
End Sub

You can download the latest jsoup jar from https://jsoup.org/download and put in in your additional libs folder.
 
Upvote 0
Top