cancel
Showing results for 
Search instead for 
Did you mean: 

Encoding problem in FTL template

itzamna
Confirmed Champ
Confirmed Champ
Hi folks,

I'm struggling with an encoding issue in my FTL template. The letters are not encoded with UTF-8 but they should. Maybe someone can help me with this?

Via webscript I fetch some data from the database and return a JSON. The JSON already contains the data with the different encoding (for example: windows-1252). Now I want to display the values from the JSON in my FTL template in a table. The result is shown in "image_1.jpg". But if I open the affected document with the Alfresco standard Web-GUI the name will be displayed as expected (see attached "image_2.jpg").
I don't know how I can prepare my FTL template that the data will be displayed correctly as in the Web-GUI too. This proves me that there is a chance to get it displayed with the correct encoding. So, what is still missing?

I've tried already to specify the following statements on the beginning of my template:

<#ftl encoding='UTF-8'>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>

But it seems that it has no effect. To display the value, there is nothing special implemented. I only read the parameter from the JSON map and put it in a usual HTML table tag. Nothing fancy:


<td>${d["name"]}</td>



Does anyone still has an idea? Do I miss somehting that should be imported in my FTL? The only imports I have in my ".get.head.ftl" are:


<#include "/org/alfresco/components/component.head.inc">
<@script type="text/javascript" src="${page.url.context}/res/components/console/consoletool.js"></@script>


Thanks!
1 REPLY 1

romschn
Star Collaborator
Star Collaborator
Can you try putting below in your ftl and see if it works for you or not.

<#escape x as jsonUtils.encodeJSONString(x)>
Your content of ftl file
</#escape>


Hope this helps.