Subject Re: [Firebird-Java] Charset problem using ISO8859_1 and UNICODE_FSS
Author Roman Rokytskyy
> Here's the transportable backup.
> ...
> I hope you can spot the bug.


As I suspected, the reason is incorrect treatment of the unicode characters
in FlameRobin. Actually, it is not the only GUI that does not handle
UNICODE_FSS correctly. IB Expert works the same. At the end of this email
you will find small program that reads raw data without any conversion from
the database and then displays them including the bytes in hex form. There
you can clearly see that first column contains UTF-8-encoded content, while
the second contains an ISO-8859-1 encoded content.

Vélez - 56 c3 a9 6c 65 7a
Vélez Sarsfield - 56 e9 6c 65 7a 20 53 61 72 73 66 69 65 6c 64

If, as an experiment, you change the

new String(longName, "ISO-8859-1")


new String(longName, "UTF-8")

you will see a '?' instead of your character:

V?lez Sarsfield - 56 e9 6c 65 7a 20 53 61 72 73 66 69 65 6c 64

In order to enter correct content into the database, you have to connect to
it using the ISO8859_1 charset in FlameRobin and IB Expert. In this case
Firebird will convert charactes from the ISO Latin 1 encoding to UNICODE_FSS

In Java you can use whatever charset you like.

Also, if I were you, I would consider switching back from UNICODE_FSS to
ISO8859_1 (if that is acceptable for you), since there is no
language-specific collation defined for UNICODE_FSS.

You can forward this email to FlameRobin team, maybe they can improve
Unicode handling there.


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class TestCharset {

public static void main(String[] args) throws Exception {

Connection connection = DriverManager.getConnection(
"sysdba", "masterkey");

try {

Statement stmt = connection.createStatement();
try {
ResultSet rs = stmt.executeQuery(
"SELECT nombre, nombre_completo " +
"FROM equipo WHERE id = 10");

if (!
throw new Exception("Should select 1 row.");

byte[] shortName = rs.getBytes(1);
byte[] longName = rs.getBytes(2);

new String(shortName, "UTF-8") + " - ");

for (int i = 0; i < shortName.length; i++) {
Integer.toHexString(shortName[i] & 0xff));
System.out.print(" ");


new String(longName, "ISO-8859-1") + " - ");

for (int i = 0; i < longName.length; i++) {
Integer.toHexString(longName[i] & 0xff));
System.out.print(" ");


} finally {

} finally {