JavaScript and Lodash "unescape" functions are not working properly

I'm trying to format a field that comes from a query with strange characters and it is displayed in a table.

There is an issue when I try to format the "Name" column with the following code:

{{ unescape(item) }}

I also have tried the Lodash version of this function:

{{ _.unescape(item) }}

The result is the same:

For example, there is a name that looks like this:

Milo\u0161 Vu\u010dkovi\u0107

and the formatted string should look like this:

Miloš Vučković

The weird thing is that if I write the exact same string instead of the "item" variable, it works.

I also have tried with a third-party library called "he.js" that also has an "unescape" function that works fine outside Retool.

Any ideas of why this is happening?

:thinking: Interesting I haven't been able to reproduce this behavior yet. I'll do a bit more testing still, but I'm curious if you can post a screenshot of the underlying table query as well?

Hi Tess, thank you for the answer. I can provide more details. In fact, I created a small app with just a simple table with similar data, and the issue still persists.

First, I imported the next CSV file into the Retool Database in a table called customer_report.

Name,Is a company,Street,Zip,City,State,Country,RFC
"D'Ann Lanning",0,,,,,,XEXX010101000
"Ilse Gaona ",0,,,,,,XAXX010101000
Estefany Garc\xeda Hernandez,0,,,,,,XAXX010101000
Jes\xfas Miranda,0,,,,,,XEXX010101000
Mar\xeda De Le\xf3n,0,,,,,,XAXX010101000
Milo\u0161 Vu\u010dkovi\u0107,0,,,,,,XEXX010101000
Monica S\xf8raas-s\xe6ther,0,,,,,,XEXX010101000
Natalia Szyma\u0144ska,0,,,,,,XEXX010101000
Nayibe Georgina Ju\xe1rez C\xe1rdenas,0,,,,,,XAXX010101000
Pavel Mare\u010dek,0,,,,,,XEXX010101000
Pawe\u0142 Siersze\u0144,0,,,,,,XEXX010101000
Sofia Lagerstr\xf6m,0,,,,,,XEXX010101000
Stefanie Geissb\xfchler,0,,,,,,XEXX010101000
T\xe9a Pietri,0,,,,,,XEXX010101000
Tam\xe1s K\xe9ri,0,,,,,,XEXX010101000
\u0141ukasz Kulczy\u0144ski,0,,,,,,XEXX010101000
\u05de\u05e2\u05d9\u05d9\u05df \u05db\u05d4\u05df,0,,,,,,XEXX010101000
\xc9lodie Laroche,0,,,,,,XEXX010101000

Then, I created a new example app with just a table with the next simple query:

SELECT *
FROM customer_report;

Finally, I tried to format the column called name with the next Lodash function:

{{ _.unescape(item) }}

I also tried the native unescape function with no luck:

{{ window.unescape(item) }}

Other Lodash functions that format Strings are working fine, like {{ _.upperCase(item) }}.

These functions work fine outside Retool. Here we have an example using Lodash unescape with the same names in a JSFiddle:

Let me know if you are able to reproduce the error.

Thanks for the help!

1 Like

Thanks so much for these details!

I think you can use JSON.parse instead -- either in a JS transformer:

...or in the column mapper:

Hi Tess, thanks again for your help, I tried to implement those solutions with no success. I used the same example that is in my preview replay and this is what I found:

  1. Using JSON.parse in a JS transformer: For some reason, no changes are visible to the "name" column using this approach.

  2. Using the JSON.parse in a column mapper: This works for some values, but other values disappear.

Any other hint will be appreciated

1 Like