The psql shell uses the code page 850, the windows use 1252. How to solve the code page of the management console?

I installed PostgreSQL, wanting to create a new database, everything is going fine until I try to use the € sign. And then I knew that the warning I get at the beginning is the reason.

The warning I get when starting my psql shell:

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. 

So, I'm going to do what I was told (from PostgreSQL Documentation 9.2 - psql ):


Notes for Windows Users

psql is built as a "console application". Since windows console windows use a different encoding than the rest of the system, you should be especially careful when using 8-bit characters in psql. If psql detects a problematic console code page, it will warn you at startup. To change the console code page, two things are needed:

  • Define the code page by typing cmd.exe / c chcp 1252 . (1252 is a code page suitable for German, replace it with your value.) If you use Cygwin, you can put this command in / etc / profile .
  • Install the Lucida Console font because the bitmap font does not work with the ANSI code page.

When I enter the cmd.exe / c chcp 1252 command , I get a syntax error. Therefore psql does not recognize the command. Out of desperation, I tried to do something in cmd.exe itself, it also does not work.

I work on Windows 7 - 64Bit.

+6
source share
2 answers

What is the character set of your database? If it is UTF-8, then before starting what you want in psql, just tell the console to use UTF-8 encoding: cmd.exe /c chcp 65001

+5
source

I had the same issue on Windows 10.

In psql type! CHCP

it showed my setup as 850. I changed it to 1252 by doing the following.

! dir detected runpsql.bat file in C: \ Program Files \ PostgreSQL \ 9.6 \ scripts

From the windows after exiting psql, I started Notebook in administrator mode and added the above REM Run psql statement chcp 1252 command

Now running without warning

+2
source

Source: https://habr.com/ru/post/955194/


All Articles