0

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.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • `Now, the correct form is to read DB in correct charset form NONE` that is simply not true. Correct way in this situation, albeit still fragile, would be to specify the connection charset exactly the same as the binary format of the textual data in the database. – Arioch 'The Mar 10 '21 at 11:47
  • is it firebird 3 or firebird 2 ? // in case of FB2 one may use SQL commands or IDEs like IBExpert to hack into "system tables" and retroactively assign proper charset to the columns. Then you would better have to copy the table onto itself to make new "format version" spread across all the rows, like `update tablename set text_blob_column = '' || text_blob_column`. But do experiments on the spare DB copy that you can always throw to recycle bin and start from fresh etalon copy on any slightest doubt. – Arioch 'The Mar 10 '21 at 11:48

1 Answers1

2

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.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197