node-odbc icon indicating copy to clipboard operation
node-odbc copied to clipboard

[HELP] Change or define charset / encoding?

Open jmbluethner opened this issue 1 year ago • 14 comments
trafficstars

Hey there!

I was wondering if there's a way to adjust the charset? I can't find anything like that in the docs.
I'm from Germany, so we have quite a lot of datasets which contain special Characters like ä,ö,ü, Unfortunately, those show up as � characters.

image

Any help would be appreciated :)

Thanks in advance and have an amazing day.

jmbluethner avatar Apr 15 '24 11:04 jmbluethner

Update: I tried to add CHARSET=UTF-8, CHARSET=ISO8859-1 and CCSID=1208 to the DSN string, but no success so far.

jmbluethner avatar Apr 15 '24 12:04 jmbluethner

Update: I tried to add CHARSET=UTF-8, CHARSET=ISO8859-1 and CCSID=1208 to the DSN string, but no success so far.

I have recently tried to use "CharSet=utf8" (without the dash), and had at least a partial success with SAP Anywhere database. Now writing to the database from node works at least for the characters supported by the locally configured codepage (in my case 1252), and maybe even some more. Sadly, at least in my setup, it did not help to write the more remote codepoints... :-\

Ted-CAcert avatar Apr 15 '24 13:04 Ted-CAcert

@jmbluethner setting the charset is a driver-specific thing, so it would help to know what driver you are using.

kadler avatar Apr 18 '24 18:04 kadler

@jmbluethner setting the charset is a driver-specific thing, so it would help to know what driver you are using.

Using the ODBC driver for SAP Anywhere 17 on Windows 10. According to ODBC Admin the version number is 17.00.11.6933.

My guess is that this is not so much an issue of the database side of the driver, but the handling by the ODBC interface itself, and probably changing the local settings of Windows changes things. My regional settings are set to Germany, which (afaik) implies codepage 1252 "for non unicode programs". The database codepage is set to 1252.

Ted-CAcert avatar Apr 25 '24 08:04 Ted-CAcert

The current design of the node-odbc, even on Windows is that it binds all character data as SQL_C_CHAR and interprets it as UTF-8. If the driver does not support setting the local encoding, then this will fail for data which isn't UTF-8.

There's an existing issue to support binding as SQL_C_WCHAR instead: https://github.com/markdirish/node-odbc/issues/292

kadler avatar Apr 25 '24 13:04 kadler

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 25 '24 00:07 stale[bot]