Re: warning about console code page on starting psql

Поиск
Список
Период
Сортировка
От Scott Robertson
Тема Re: warning about console code page on starting psql
Дата
Msg-id 549275CC.4010607@gmail.com
обсуждение исходный текст
Ответ на Re: warning about console code page on starting psql  (David Johnston <david.g.johnston@gmail.com>)
Ответы Re: warning about console code page on starting psql  (Martin Steer <martinsteer@maxi.net.au>)
Список pgsql-novice
SOLVED, see below

On 12/17/2014 2:06 PM, David Johnston wrote:
On Tuesday, December 16, 2014, David Johnston <david.g.johnston@gmail.com> wrote:
Forwarding to -docs for now.  

I suggest simply dropping the "cmd.exe /c"part from the docs and mention that the command should be run from an active console.  A recommendation for a batch file or similar would be nice.  I may put together an actual patch if I get a chance and don't see one come across but for now just reporting this.  Would want to research methods for making both these items persist and recommending such.  See my other curiosities below...

David J.

---------- Forwarded message ----------
From: David G Johnston [via PostgreSQL] <ml-node+s1045698n5831042h26@n5.nabble.com>
Date: Tuesday, December 16, 2014
Subject: Re: warning about console code page on starting psql
To: David G Johnston <david.g.johnston@gmail.com>


Stephen Cook-2 wrote
On 12/16/2014 11:10 PM, Scott Robertson wrote:
> 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.

Do not type the "cmd.exe /c" part. This will run a new instance of "cmd"
(the Windows command-line console); "\c" means "run the following
command"... So you are basically starting a new console, changing the
code page within that new console, and exiting back to your original
console.

Instead, once you have a command prompt, use "chcp 1252" to change the
code page of the Windows console to match the code page "psql" expects
from Windows. Then you can run "psql" without the warning. You will have
to do this each time you open a new command line console, before running
"psql", as far as I can tell.

-- Stephen
So basically the documented fix is useless.  At least a "/k" would keep the new console with altered code page around for interactive use but the /c switch simply kills the console after running a single command whose sole purpose is to change the to-be-killed console's codepage.

It is implied that since you are chasing the console codepage that the target value would be whatever Window's is using...but that could be made more clear as well.

Encodings are confusing and this doesn't even mention using windows psql against Linux or how Unicode would fit in - though external notes indicate that the font change suggestion also solves Unicode characters as well as dealing with ANSI...

http://ss64.com/nt/chcp.html

David J.

The only saving grace I can see is that it does make cmd.exe explicit since Windows does have PowerShell, though how it behaves I do not know either....

David J. 

Case closed and much learned. The documentation was depending on me remembering some things learned from a dos class almost 20 years ago, haven't used the command line console since.

SUMMARY OF SOLUTION
start console cmd.exe
use icon upper left on title bar to change font to Lucida Console
change to root directory: cd\
check the code page to confirm it's wrong: chcp
change the code page: chcp 1252
change to postgresql directory; in my Windows 7 it's: cd program files\postgresql\9.4\bin\
open psql (in same console) as superuser so operating system user password isn't expected: psql -U postgres
prompt comes up for postgres password

RESULTS:
Microsoft Windows [Version 6.1.7600]

C:\Users\Luther>cd/

C:\>chcp
Active code page: 437

C:\>chcp 1252
Active code page: 1252

C:\>cd program files\postgresql\9.4\bin\

C:\Program Files\PostgreSQL\9.4\bin>
C:\Program Files\PostgreSQL\9.4\bin>psql -U postgres
Password for user postgres:
psql (9.4rc1)
Type "help" for help.

postgres=# \c testdb2
You are now connected to database "testdb2" as user "postgres".
testdb2=# select * from jedstblinmelsdb;
 key | name | address
-----+------+---------
(0 rows)



This email has been checked for viruses by Avast antivirus software.
www.avast.com


В списке pgsql-novice по дате отправления:

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: Why "vacuum_freeze_min_age" parameter has context as "USER" ?
Следующее
От: Michael Wood
Дата:
Сообщение: Re: warning about console code page on starting psql