Batch script does not change console code page from command prompt - windows

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"

Related

Command Prompt in Windows 11 displays 'SeekTools: Seek for the Project Tool Folder (give option '-h' for help)' Error

Whenever the command prompt is opened, the 'SeekTools: Seek for the Project Tool Folder (give option '-h' for help)' Error is displayed, as shown in the image below.
Command Prompt
We also deleted the 'Environment Variables' related to this. But still we get this Error displayed on the Command Prompt.
It could be helpful, if the reason behind this issue is informed. As it is not clear where to start resolving this issue from.

Run selected line in notepad++ console

This might seem a bit too obvious but I am stuck with it anyway.
I am editing an ffmpeg code in notepad++ and I want to run the selected line of code directly in notepad++ console (nppexec plugin console).
say, I have four lines of code, and I want to run only the second line (selected line):
currently, I am coping the line and pasting it in the console and hitting enter. I know it is very noobie!
Please help to achieve this with a shortcut or something.
Once I created a small nppexex script, to run an external command on the selection, based on that you can use a nppexec script like:
sel_saveto c:\Temp\NPP_Selection.bat
cmd /c c:\Temp\NPP_Selection.bat
Please save your file with the ffmpeg command with ansi encoding (with UTF8 there was an error with some strange characters at the start of the selection).
The script stores the selection in a bat file and then runs it with cmd /c

Active perl and local encoding issue

am trying to using actvperrl to install prerequsist for bugzila but when trying to run this script from cmd running as administrator
ppm install TimeDate
I get the following error
ppm install failed: The locale codeset (cp720) isn't one that perl can decode, s
topped
even if am using English , any idea how to fix that
It seems like a bug in on windows for number of the active console code page cp720.
You can change this code with command prompt by inserting chcp nnn, where nnn specifies the code page ( example : chcp 850), you can find a list of cp here. but you must repeat the same steps each time you want to open tlmgr.
You can automate the previous steps by inserting the command chcp nnn directly in cmd.
chcp 850

psql shell uses code page 850, windows uses 1252. How to solve change console code page?

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 cannot change RailsInstaller command prompt buffer size

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...

Resources