Character encoding problems when receiving dynamic components from a brokerage database - Tridion, Oracle, JSP

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

I have a scriptlet that calls a brokerage database to generate an XML string and then parses XSL.

I canceled my code when debugging this problem, and the script now looks like this:

..... 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 manually override this code and set the xml string content in the code, the data is displayed correctly on the 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 component is published to the content broker database using CT with the output format set to "XML format".

The publication target is configured as the target language: JSP and default code code: Unicode UTF-8

When I view the contents with this CT, 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 also happens when previewing through the template builder.

The broker DB is Oracle DB (Oracle Database 11g Enterprise Edition Release 11.2.0.2.0) and I checked the charecter set

 SQL> select * from v$nls_parameters where parameter like '%CHARACTERSET%'; PARAMETER VALUE NLS_CHARACTERSET UTF8 NLS_NCHAR_CHARACTERSET UTF8 

Does anyone else come across examples like this before. It seems that there is a problem with the database storage, connection to the database or cp.getContent (); Method.

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

Regards, Chris

+6
source share
2 answers

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

+1
source

Character encoding problems can be quite complex. In your case, since you have already done quite some research, I would start checking that the jsp file has the correct page encoding set:

 <%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> 
0
source

All Articles