Jump to content

Problem using JasperCompileManager with encodings


stradale

Recommended Posts

In the jrxml I'm trying to compile, there are several textfields with portuguese characters: ç, õ, etc.

If I compile this jrxml using iReport, they are correctly displayed when running the report, however, if I use my custom compiler, they are not. 

The code is pretty straightforward:

 JasperCompileManager.compileReportToFile(file.getAbsolutePath(), StringUtils.replace(file.getAbsolutePath(), ".jrxml", ".jasper"));

I know I'm missing something, I just cant put my finger on what. Do I need to set the .jasper encoding? If so, how do I do that? JRProperties.setProperty("net.sf.jasperreports.export.character.encoding", "UTF-8") ?

 

ps: the first line of my .jrxml file:

<?xml version="1.0" encoding="UTF-8"?>

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

On each text field check the encoding. The default is cp1252 (Western Europe). I had exactly the same problem with encoding - I changed it manually to Western Europe (cp1500) and I had Polish characters.

I am not sure what codepage uses Windows in Portugal, but I am sure you will find the right one :)

By the way, there is option defaul encoding hidden in configuration in iReport(Options/General/Jasperproperties/net.sf.jasperreports.default.pdf.encoding for pdf and net.sf.jasperreports.export.character.encoding for others). Unfortunately, for me it worked only for "new" fields (it seemed that in all the encoding was changed but there was no effect until I changed it again, manually, field by field)

HTH

Paweł

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...