SK12345
SK12345

Reputation: 101

How to set Client_Encoding

I'm using NodeJS to get some data from a PostgreSQL database and render it on the web. When I make a query on SQL Shell(psql) everything looks fine but when I console.log that same data from NodeJS, all the special characters are replaced with gibberish. The encoding for this database is

- Encoding: UTF8
- Collation: French_France.1252
- Ctype: French_France.1252

I tried to set Client_Encoding to UTF8 but when I reconnect to the database I find out that it is still not set. Also I get this warning each time I connect to the database (Just in case it may cause smth)

WARNING: Console code page (850) differs from Windows code page (1252)
     8-bit characters might not work correctly. See psql reference
     page "Notes for Windows users" for details.

My OS is Windows 8 and PostgreSQL version is 10.x.

Upvotes: 1

Views: 2548

Answers (1)

Dialecticus
Dialecticus

Reputation: 16769

After a long search I have found a solution that I want to share now.

Change your ODBC DSN connection string to include this: ConnSettings=SET CLIENT_ENCODING TO 'UTF8';

Upvotes: 2

Related Questions