1

I'm using node/odbc for connection to a Firebird database, but I cannot see the characters with accent and other Spanish characters.

I tried to set the charset in the connection string

const odbc = require('odbc');
odbc.connect('DSN=mydnsname; charset=UTF8');

But not runs. If I connect with access to the odbc database the characters are shown right.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
wakeup
  • 67
  • 7
  • should there be a space? `me; charset` ? Also, why not using some direct library for Firebird connection in node.js? ODBC for Firebird seems almost abandoned... Try `WIN1252` or `WIN1250` charsets. Try `UTF-8`. Try `lc_ctype=` Firebird-specific setting, though this one is for direct libraries, i am not sure ODBC driver understands it. – Arioch 'The Jul 21 '20 at 14:30
  • What is the character set of the column in the database, is it possibly `NONE`? Likely access is defaulting to the default character set for your locale (eg `WIN1252`), and if you specify character set `UTF8` as connection character set, while the column character set is `NONE`, then no transliteration takes place and you end up with mojibake or other issues. – Mark Rotteveel Jul 21 '20 at 14:39
  • Arioch I tried without the space with the same result. I tried "node-firebird" library but I had problems too. Do you know any other? I tried WIN1252 and WIN1250 with the same result. Thanks – wakeup Jul 22 '20 at 11:02
  • Mark you are right the database character set is NONE, but I can't change the database because is a database of my client. But I can see the special characters without problems with Microsoft Access using the odbc interface and also with other firebird clients. Thanks – wakeup Jul 22 '20 at 11:04
  • Meanwhile I tried with another node extension "firebird" and I had the same problem. I creadted a database with charset utf8 and it runs well but it I created the database with charset none it doesn't print well special characters. The problem is I can't change the original database... – wakeup Jul 22 '20 at 12:28
  • Then you will probably need to do something like `select cast(column as varchar(200) character set win1252) from ...` (replace `varchar(200)` with an appropriate length and `win1252` with the right character set) to ensure the value is converted to a type with the actual storage character set, so that it can then be transliterated correctly to the connection character set. – Mark Rotteveel Jul 22 '20 at 13:20
  • Mark thanks a lot! that runs, although I don't know if it is the better solution it doesn't seem very elegant. – wakeup Jul 23 '20 at 09:06
  • did you try specifying `WIN1252 or WIN1250 charsets` at the connection string? – Arioch 'The Jul 23 '20 at 10:58
  • Arioch, yes I did but not runs – wakeup Jul 28 '20 at 08:16
  • @MarkRotteveel charset=UTF8 in the connection string, and "cast(column as varchar(200) character set win1252" runs well in Windows, but in ubuntu y only get the first character of the string with the same program. Do you know why? – wakeup Nov 30 '20 at 15:56
  • @wakeup Not really, I suggest you ask a question on the firebird-support Google Group. – Mark Rotteveel Dec 01 '20 at 12:34

0 Answers0