BIRT Report having trouble with accented characters coming from database

42 Views Asked by At

I have some reports made on Spanish by someone. These work properly if I install the Tomcat server on Windows, however we recently switched the whole stack to Ubuntu and now I am facing this problem where all the accented characters look like this.

enter image description here

"País de Origen" should be showing México, for example. If you can see, the word País as template words do show correctly. I am querying this data from a MariaDB instance.

Any help appreciated

2

There are 2 best solutions below

0
John On BEST ANSWER

Thanks a lot for your suggestions, I managed to fix it by following my only clue which was that the template accents were rendered correctly but dynamic data wasn't.

With this I edited the database connection URL to jdbc:mysql://db:3306/mycooldb?characterEncoding=UTF-8 and that fixed it.

This setting I got from this article: https://balusc.omnifaces.org/2009/05/unicode-how-to-get-characters-right.html

Usually the database's JDBC driver is smart enough to use the database and/or table specified encoding for querying and storing the data. But in worst cases you have to specify the character encoding in the connection string as well. This is true in case of MySQL JDBC driver because it does not use the database-specified encoding, but the client-specified encoding. How to configure it should already be answered in the JDBC driver documentation. In for example MySQL you can read it here:

jdbc:mysql://localhost:3306/db_name?useUnicode=true&characterEncoding=UTF-8

1
hvb On

BIRT (and Java) use Unicode for strings.

So this is probably a matter of encoding configuration for the database connection.

Another thing that could complicate things are fonts.

Probably you developed your report with windows fonts in mind, e.g. Arial. Since these fonts are not available on Linux, BIRT uses a replacement font. I suggest you copy the necessary *.ttf files to a location on your Linux machine where BIRT will find it through the fontsConfig.xml configuration file.