Jump to content

Problem with UTF-8 encoding in i18n files


feko

Recommended Posts

Hi,

I have a problem with special characters in a UTF-8-encoded i18n file. I've checked the forums but haven't found any post about exactly the same problem.

Here's the problem:

If I enter special characters directly in the report designer/jrxml file, they show up correctly in the output (internal viewer and PDF). When using the msg function or a $R reference, the output is garbled. It does work if I encode the properties file in ANSI. Unfortunately, this is unacceptable as I need to re-use an existing file from another application which expects UTF-8.

I've created a simple report file to illustrate the issue (attached) with two properties files (i18n.properties and i18n_fr.properties with a single property "title") in the same folder as the jrxml file. The french translations do get picked up correctly but special characters in them are displayed incorrectly.

The same thing happens on Windows (Vista) and Mac OS 10.5 using Java 6.

What am I doing wrong?

Thanks,

Felix

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Hi Giulio,

This answers my question. Unfortunately this means that I cannot use the same i18n resources for the whole project. Standard resource bundles for reporting, flat UTF-8 for the ZK UI, snif...

Thanks a lot anyway,

Felix

Link to comment
Share on other sites

Felix,

It's not an iReport (or JasperReports) limitation that bundles cannot include UTF-8 characters. It's the Java specification. Valid Java bundles must contain only ascii characters.

Perhaps you can find a way to sync your UTF-8 encoded files into valid ones for use by iR/JR by using native2ascii (which is included with Java)

Regards,
Matt

Link to comment
Share on other sites

Hi Matt,

 

Thanks for your hints - in fact, I had already figured this out. I realize I was completely on the wrong track before :-)

Anyway, I fixed this by converting the files using the Maven plugin org.codehaus.mojo:native2ascii-maven-plugin. I attached a sample config in case anyone using Maven has the same problem.

Thanks,

Felix

Code:
<plugin>  <groupId>org.codehaus.mojo</groupId>  <artifactId>native2ascii-maven-plugin</artifactId>  <executions>    <execution>      <id>i18n</id>      <goals>        <goal>native2ascii</goal>      </goals>      <configuration>        <dest>${project.build.directory}/classes</dest>        <encoding>UTF8</encoding>        <includes>i18_utf8*.properties</includes>	<src>${basedir}/src/main/resources</src>      </configuration>    </execution>  </executions></plugin>
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...