J John.Reacher Member Nov 14, 2022 #1 Hello everyone. I made a project that took a string from an edit box and converted it to html. This program was working well until I put html tags in the edit box, the program stopped. How to put html tags in html. B4X: sb.Append($"<html><head><title>Title</title></head><body><p>"$) /////////////// sb.Append($"<html><head><title>Title</title></head><body><p>this is a sample that how to make html</p></body></html>"$) ///////////// sb.Append($"</p></body></html>"$) Last edited: Nov 14, 2022
Hello everyone. I made a project that took a string from an edit box and converted it to html. This program was working well until I put html tags in the edit box, the program stopped. How to put html tags in html. B4X: sb.Append($"<html><head><title>Title</title></head><body><p>"$) /////////////// sb.Append($"<html><head><title>Title</title></head><body><p>this is a sample that how to make html</p></body></html>"$) ///////////// sb.Append($"</p></body></html>"$)
DonManfred Expert Licensed User Longtime User Nov 15, 2022 #2 John.Reacher said: the program stopped Click to expand... Post the full error! Upload a small project showing the problem. Away from that i dont see how the code above will crash the app. Upvote 0
John.Reacher said: the program stopped Click to expand... Post the full error! Upload a small project showing the problem. Away from that i dont see how the code above will crash the app.
P PaulMeuris Well-Known Member Licensed User Nov 15, 2022 #3 < => < > => > ' => "e; ... Upvote 0
E emexes Expert Licensed User Longtime User Nov 15, 2022 #4 PaulMeuris said: < => < > => > ' => "e; ... Click to expand... ? a beautifully-concise distillation of: https://www.w3schools.com/html/html_entities.asp (perhaps with a gentle hint of: internet search is your friend) Last edited: Nov 15, 2022 Upvote 0
PaulMeuris said: < => < > => > ' => "e; ... Click to expand... ? a beautifully-concise distillation of: https://www.w3schools.com/html/html_entities.asp (perhaps with a gentle hint of: internet search is your friend)
E emexes Expert Licensed User Longtime User Nov 15, 2022 #5 John.Reacher said: I made a project that took a string from an edit box and converted it to html. This program was working well until I put html tags in the edit box, the program stopped. How to put html tags in html. Click to expand... Rather than you (or your users) have to manually type those HTML entity codes, I'd run the sample HTML through a function eg: B4X: Sub SampleHtml(H As String) As String Dim S As String = H S = S.Replace($"<"$, "<") S = S.Replace($">"$, ">") S = S.Replace($"""$, """) S = S.Replace($"'"$, "'") S = S.Replace($"&"$, "&") Return S End Sub and then I think your code would like like: B4X: sb.Append($"<html><head><title>Title</title></head><body><p>"$) /////////////// sb.Append(SampleHtml($"<html><head><title>Title</title></head><body><p>this is a sample that how to make html</p></body></html>"$)) ///////////// sb.Append($"</p></body></html>"$) Upvote 0
John.Reacher said: I made a project that took a string from an edit box and converted it to html. This program was working well until I put html tags in the edit box, the program stopped. How to put html tags in html. Click to expand... Rather than you (or your users) have to manually type those HTML entity codes, I'd run the sample HTML through a function eg: B4X: Sub SampleHtml(H As String) As String Dim S As String = H S = S.Replace($"<"$, "<") S = S.Replace($">"$, ">") S = S.Replace($"""$, """) S = S.Replace($"'"$, "'") S = S.Replace($"&"$, "&") Return S End Sub and then I think your code would like like: B4X: sb.Append($"<html><head><title>Title</title></head><body><p>"$) /////////////// sb.Append(SampleHtml($"<html><head><title>Title</title></head><body><p>this is a sample that how to make html</p></body></html>"$)) ///////////// sb.Append($"</p></body></html>"$)