Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: Warning: Console code page (437) differs from Windows code page (1252)

Using PostgreSQL when I connect to a db using \c testdb inside PostgreSQL Database SQL Prompt. I successfully connect to the db but getting the following warning:

postgres-# \c testdb
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
You are now connected to database "testdb" as user "postgres".
testdb-#

What does this warning mean? How to resolve it?

like image 747
Yousuf Memon Avatar asked Dec 27 '13 02:12

Yousuf Memon


2 Answers

From the psql documentation:

psql is built as a "console application". Since the Windows console windows use a different encoding than the rest of the system, you must take special care when using 8-bit characters within psql. If psql detects a problematic console code page, it will warn you at startup.

To change the console code page, two things are necessary: Set the code page by entering cmd.exe /c chcp 1252. (1252 is a code page that is appropriate for German; replace it with your value.) If you are using Cygwin, you can put this command in /etc/profile.

So to remove that warning you need to execute chcp 1252 before you enterpsql. Using chcp without parameters gives you the current codepage.

like image 117
dvdgsng Avatar answered Sep 30 '22 09:09

dvdgsng


The default codepage for CMD.exe is different than the default for postgres... To change for CMD.exe using the REGISTRY try this:

  1. Start -> Run -> regedit
  2. Go to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
  3. Add new string value named "Autorun" with value "chcp 1252"

Then reopen CMD.exe

like image 38
user3344137 Avatar answered Sep 30 '22 09:09

user3344137