How to read data with charset NONE from Firebird database?

1.3k Views Asked by At

There are some old database that is based on NONE encoding and have unique Latin characters like á and are read like ? . Now, the correct form is to read DB in correct charset form NONE and it was specified in connection string, but the library FirebirdSql.Data.FirebirdClient doesn't read these values also if is specified that charset = NONE. How can I resolve this situation? The result now is like "edit�es", but needs to be with an apostrophe. I'm using .NET Core and FirebirdSql.Data.FirebirdClient version 7.10.1, I tried to downgrade and is the same.

1

There are 1 best solutions below

0
On

If you know what the actual character set was of the data stored in those columns, you can cast the data to the right character set.

For example if the characters are expected to be windows-1252 (WIN1252):

select cast(yourcolumn as varchar(100) character set win1252) from yourtable
-- replace varchar(100) with the actual size

For a more permanent solution, create a new database with the right character set(s), and pump the data over, applying the right transformations.

Be aware that specifying NONE as the connection character set is almost never the right solution, even when reading from a databases that uses NONE as the column character set, it is also possible that the cast trick above will not work correctly when you have used NONE as the connection character set, in that case it is better to specify UTF8 as the connection character set.

Usually, specifying the expected character set of the data as connection character set will allow you to read the data as well, but details vary per driver, and I'm not sure of the behaviour of the Firebird ADO.net provider.