Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Character encoding issues when getting dynamic components out of a Broker DB - Tridion , Oracle , JSP

I am having issues with character encoding when viewing dynamic content from a broker database.

I have a scriptlet that calls the broker DB to generate a XML string and is then parsed by a XSL.

I have stripped back my code when debugging this issue and the script now looks like:

.....

strOutput= "<xml>";
ComponentPresentationFactory cpf = new ComponentPresentationFactory(PublicationID);

for (int i =0; i < itemURIs.length; i++)
{
ComponentPresentation cp = cpf.getComponentPresentation(itemURIs[i], strComponentTemplateURI);  
      if(cp != null){
        String content = "";
        content = cp.getContent();
        strOutput += content;
      }
}
strOutput+= "</xml>";

......

When i manualy overide this code and set the xml string content manualy in the code the data is displayed correctly on screen i.e. :

.....

strOutput= "<xml>";
ComponentPresentationFactory cpf = new ComponentPresentationFactory(PublicationID);

for (int i =0; i < itemURIs.length; i++)
{
ComponentPresentation cp = cpf.getComponentPresentation(itemURIs[i], strComponentTemplateURI);  
      if(cp != null){
        String content = "<xml><dynamicContent><subtitle><![CDATA[Außenbeleuchtung]]></subtitle></dynamicContent></xml>";
        strOutput += content;
      }
}
strOutput+= "</xml>";

......

The conponent is published to the content broker DB using a CT with a output format set to "XML Format".

The publication target is set up as Target Language : JSP and Default Code Page : Unicode UTF-8

When i preview the content using this CT then the data is displayed correctly:

<dynamicContent>
    <tcm_id>tcm:345-23288</tcm_id>
    <title><![CDATA[LED Road R250 - Maximum LED performance for street and highway illumination]]></title>
    <subtitle><![CDATA[Außenbeleuchtung ]]></summary>
</dynamicContent>

This is also the case when previewing through template builder.

The Broker DB is an Oracle DB (Oracle Database 11g Enterprise Edition Release 11.2.0.2.0) and i have checked the charecter set

SQL> select * from v$nls_parameters where parameter like '%CHARACTERSET%'; 

PARAMETER VALUE 

NLS_CHARACTERSET UTF8 
NLS_NCHAR_CHARACTERSET UTF8 

Has anyone else come accross any examples like this before. It looks like there is an issue with either the DB storage , The connection to the DB or the cp.getContent(); method.

Any help would be greatly apreciated and if you have any further questions please let me know.

Regards, Chris

like image 858
Chris Eccles Avatar asked Nov 23 '12 17:11

Chris Eccles


1 Answers

Have a look at this article which discusses ways to solve encoding issues: http://elenaserghie.blogspot.ca/2012/01/7-clues-to-solve-character-encoding.html

like image 111
Nickoli Roussakov Avatar answered Sep 21 '22 15:09

Nickoli Roussakov