Jump to content
We've recently updated our Privacy Statement, available here ×

UTF-8 data from database not displaying


uhurusurfa

Recommended Posts

Any non standard character that is retrieved from a database (anything with accent/umlaut etc) is not printing correctly or causes complete failure to print of the text field it renders in (although not sure what the exact combination is that causes the failure to print the field versus printing incorrect characters). We are using mySql as DB backend with JDBC connection for our data source.

 

The problem exists using 2.01, 2.00, 1.3.4, 1.3.3 and 1.3.2 (have not tested on earlier versions but assume same holds).

 

I have lost count of the number of reports in the forums I have come across with identical problem but none seem to have a solution or if there is everyone is keeping very quiet about it.

 

Have checked:

1. UTF-8 set as default encoding in XML report definition header and in encoding property.

2. DB encoding - set to UTF-8 at all levels including forcing UTF-8 encoding on any connection irrespective of request params

3. JDBC connection string - added "charSet=UTF-8&useUnicode=true&characterEncoding=UTF-8" to ensure no problems there but still no joy

4. Verified that pasting static text with same accented characters into text field that renders the text from the DB. The static text renders correctly but DB text does not so text field config cannot be the problem since I also edited XML file and verified detected encoding is UTF-8.

 

The characters render correctly in a web browser using our application and the JDBC connection is identical to the one used for Jasper, the HTTP data stream is UTF-8 encoded and the HTML page header specifies UTF-8 encoding so we are certain that it is not a DB issue.

 

Using the iReports build option "Text Preview (iReports)" the text is correct in the output file and editing the file confirms that UTF-8 encoding is detected but using HTML, PDF, ODF or the "JRViewer Preview" options does not.

 

If anyone has the key to this seemingly extensively reported problem it would be very much appreciated.

 

Post edited by: uhurusurfa, at: 2007/10/01 12:03

 

Post edited by: uhurusurfa, at: 2007/10/01 12:47

Post edited by: uhurusurfa, at: 2007/10/01 12:47

Link to comment
Share on other sites

  • 6 months later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

I have the same problem, has anyone found a solution for this.

I have tried to check the bug tracker but the bug was not reported here, not open nor closed.

So i guess there must be a solution.

 

I can say that i am using a MS SQLServer 2005.

Tomcat 5.5 running spring/hibernate

 

The fields that i am trying to retrieve are encoded in nvarchar (the unicode version of varchar).

They work fine in spring i am only having trouble with jasper reports. Is there any way to debug a jasper report?

 

Also i am using localisation with ressourcebundles. The contents of these are shown in pdf files after i changed the contents from UTF-8 to ISO-8859-1 with unicode-escapes.

Post edited by: 4nd3r5, at: 2008/04/04 15:07

Link to comment
Share on other sites

The problem was not in Jasper. check that you have all readers and writers instantiated on both HTTP connection and DB connection set to UTF-8. Dont assume the reader or writer is UTF-8

 

for tomcat sepcifically:

1. Set the property URIEncoding=UTF-8 in the config

2. Set the response writer using : resp.setContentType( "text/html; charset=UTF-8" );

 

Verifying that you are definitely seeing UTF-8 characters can be a trying exercise as there are automatic conversions that take place base on LOCAL settings that you are not aware of and will fool you into thinking you are seeing UTF-8 when in fact it is Latin1 or some other character set.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...