I need to replace all special characters with their UNICODE counterparts, and I know the first step is to use the URLEncode function in Quickbase, but what next?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

I have several input text boxes that are appended to a formula text field which includes a html table to be send to a word document with Exact Forms. Unfortunately, if any special characters such as < , ' etc. are added to the text input boxes, they are replaced with white space in the Word document. My initial thought was to use the URLEncode function on each text box, but then, when it is imported into Word, it is still encoded. Any thoughts on where to go from here? Is there a simple way to check for special characters and replace them with their Unicode or HTML counterparts? 

Photo of Ursula Ll

Ursula Ll

  • 1,562 Points 1k badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,044 Points 20k badge 2x thumb
You are confusing URLEncoding with HTMLEncoding. See this answer:

http://stackoverflow.com/questions/1812473/difference-between-url-encode-and-html-encode#answer-1812...


QuickBase HTMLEncodes some special characters (ie "<", ">" etc) as a security precaution to prevent users from entering raw HTML that may be problematic.

You will need something like this code operating within the Exact Form to decode the HTML:

var encodedText = "&lt;Foo Bar&gt;";

var decodedText = $("<div/>").html(encodedText).text();

If you need individualized help fixing the problem fee free to contact me off-world using the information in my profile.
Photo of Ursula Ll

Ursula Ll

  • 1,562 Points 1k badge 2x thumb
Thank you so much for the response! I was researching the HTMLEncoding right before I recieved this alert.  I had thought URLEncode because it encodes the special characters, but since it encodes everything, trying to decode that seems like a hassle I don't want to deal with.  

I guess my question goes further than that. Is there a way for me to check if a text input box contains any special characters, and find a way to replace them with their HTML counterparts? For example: a user inputs "Requested 10 units > than original request." This text field would break once imported into the html field because of the character ">". If I can find a way to search for all of those special characters, and replace them with html codes, prior to importing into the html field, then that would solve my problem. My alternate solution is to create a script and do some regex to find all of the characters, and replace them one by one, but I was looking for a Quickbase solution, if there was one.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,044 Points 20k badge 2x thumb
QuickBase will always converts special character such as "<" or ">" entered into a form control into character entities (:lt; or ;gt;) and there is no bypass to this conversion. They do this and other conversions to prevent you from entering unrestricted raw HTML. You can go ahead and save HTML into a text field but special characters will be converted to character entities. When the data comes back out of the record you will have to convert the character entities to raw HTML using script in the exact form.
Photo of Ursula Ll

Ursula Ll

  • 1,562 Points 1k badge 2x thumb
That is what I was afraid of! Ok well, if that is the case, I will start setting something up, in the meantime, I will see if it is even an issue, maybe it never comes up. Better safe than sorry! Thanks so much for the input Dan, I appreciate it!