When running psql <database_name> from the command line I've been getting this warning:
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.
I found a solution for this found from another question however it only gets rid of the warning for that session and I'm trying to completely get rid of the warning. It's been mentioned that I could go into C:\Program Files\PostgreSQL\9.6\scripts\runpsql.bat and cmd.exe /c chcp 1252 or chcp 1252 near the top of the batch file to remove this warning, however that has not been working for me.
When executing the batch file, it does print out a line console code page and the warning doesn't appear. However when I run psql [database] from the command prompt, the warning still persists. Does anyone know how to permanently remove the warning?
I am using PostgreSQL 9.6.1 and Windows 7 64-bit.
Look here: psql: Init files?
You can locate the file PSQLRC.CONF and add in it a line like, perhaps,
\set ENCODING "whatever encoding you want"
How to enter in chinese filename in Windows command prompt window?
Suppose you have a filename 公司File.txt somewhere.
And you want to execute the md5sum.exe program on that file.
md5sum.exe 公司File.txt
You will get...
md5sum.exe: ??File.txt: Invalid argument
Thanks.
You should be able to do
chcp 1201
in the command prompt, if you have installed the Chinese language pack. You could also try 65001, but apparently this is not compatible with your Chinese file name.
I just did a fresh install of Postgres 9.3.5 onto my Windows 7 machine. My machine's locale is "Japanese (Japan)". When I run psql at the command prompt (or PowerShell), this happens:
If I run psql --help, the eldritchness increases:
I get normal output if I switch my locale back to "English (United States)", but this is a time-consuming process that involves restarting my computer.
Question: is there a way to make psql display normal output even when in a Japaese locale; OR, is there a way to switch locales (or make psql believe that I have switched locales) that is fast and does not involve restarting my computer?
Run in the unicode codepage - chcp 65001, or run cmd as cmd.exe /k chcp 65001.
For frustrating historical reasons Windows command prompts run in an ANSI codepage by default.
I have installed PostgreSQL, wanting to set up a new database, everything is going fine, until I am trying to use the € sign. And then I knew, that warning I get in the beginning is for a reason.
The warning I am getting at starting up my psql shell is:
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 am going to do as I am told (from PostgreSQL Documentation 9.2 - psql):
Notes for Windows Users
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.
Set the console font to Lucida Console, because the raster font does not work with the ANSI code page.
When I type the cmd.exe /c chcp 1252 command I get a syntax error. So psql, doesn't recognize the command.
Out of desperation, I was trying to do something in cmd.exe itself, does not work either.
I work in Windows 7 - 64Bit.
What is your database Character Set? If it is UTF-8, then before running, what ever you want in psql, just tell the console to use the UTF-8 encoding:
cmd.exe /c chcp 65001
I had the same problem in Windows 10.
In psql type ! chcp
it revealed my setting as 850. This I changed to 1252 by doing the following.
! dir revealed a file runpsql.bat in C:\Program Files\PostgreSQL\9.6\scripts
From windows after exiting psql I ran Notebook in Administrator mode and added above the REM Run psql statement the command chcp 1252
Now runs without the warnings
As far as I know, in SQL shell you just need to type \! chcp <codepage_you_need>.
Still, after that, you might encounter another issue:
In order to solve this problem you need to go to properties (left upper corner) -> Fonts -> choose Lucida Console.
Then type \! chcp 1251
After that, everything must be alright.
I was able to fix this by running SET CLIENT_ENCODING TO 'UTF-8'; in the sql bash
I had the same problem in Windows 8.
You have to set the chcp to 1252.
With the command cmd.exe /c chcp 1252, or, if you are using powershell: powershell /c chcp 1252.
You can also use powershell /c chcp 1252.
But you have to type it before enter in the psql console.
Edit runpsql.bat (folder ...\PostgreSQL\XX\scripts)
On the next line after #echo off write: cmd /c chcp 1252 and save (you need admin permissions).
Screenshot runpsql
Results
I'm using Windows7, and I installed Ruby on Rails with RailsInstaller. This comes with "Command Prompt with Ruby and Rails", which I think is just a regular cmd prompt that automatically starts Rails...
Anyway, the problem I'm having is that I cannot change the buffer size. I have changed the buffer size to 999 in the Options tab of the Properties, but to no avail.
I've done the same thing to the regular command prompt that comes with Windows and it worked.
So I solved my problem. I could get the buffer size working correctly in the regular Windows command prompt, so I just made another shortcut to that, and then in the Properties->Shortcut tab I changed Target to C:\Windows\System32\cmd.exe /E:ON /K C:\RailsInstaller\Ruby1.9.2\setup_environment.bat C:\RailsInstaller
Still not sure why changing Options on the cmd prompt that came with railsinstaller didn't work though...