简体   繁体   中英

Codepage problem (e.g. german umlauts) with Node.JS + ibm_db + DB2 LUW 9.7 on Windows

We can successfully access IBM DB2 LUW Server 9.7 from Node.JS on Widows client using the npm package ibm_db.

But we do have a problem with the chacarter encoding in the result set of a ibm_db SQL query. The data in the JavaScripte result set is already misformed when it comes to the german umlauts äÄöÖüÜß.

If we do the identical SQL query at the command line (db2cmd.exe), everything is fine including the umlauts.

If we check with JavaScript the encoding of the umlauts in the SQL result set as interger (string.charCodeAt(index)) we find the umlauts already misformed. All different umlauts have been converted into one and the same dec:65533/hex:FFFD/char:' '.

We checked also the SQL column charset within the database with:

select name,tbcreator,codepage from sysibm.syscolumns where ...

giving the result 1252.

Other futile attempts:

  • Using SL CAST(....CCSID ####)
  • setting property in db URL (which connection property is the one to use? Documentation hard to find)
  • setting db_options['codeSet'] to 1252, windows-1252, UTF-8, 1208... when opening connection ibm_db.openSync(db_url, db_options);

Hmmmm....here I do stuck a litte. What's wrong?

Thx for any help.

Environment:

  • Windows 10
  • node.js 10.15.1
  • ibm_db 2.5.0
  • npm 6.4.1
  • IBM DB2 Server for LUW 9.7

Have you tested setting the Windows system environment variable DB2CODEPAGE=1208 ? ( you may need to restart after setting it , to allow your stack to pick it up)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM