0

I have in my database records which contains Polish characters like: ś, ć, ż, ź.

It happen to be a problem for me when I try to execute some of the SELECT statements..

Because I get my text but instead of characters I wrote above I get: <c4><85>.

I bet there is a way I can change encoding for example for utf-8, but how can I do that for simple query like select * from table?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Grzzzzzzzzzzzzz
  • 1,301
  • 4
  • 20
  • 33
  • Which programming language do you use? Which SQL tool/GUI do you use to run the `select` statements. –  Feb 04 '13 at 09:49
  • You need to provide more detail. PostgreSQL version? What client are you using - `psql`, pgadmin3, something else? If `psql`, what platform are you on and what locale is that platform in? There are known problems on Windows with psql on the cmd.exe console. – Craig Ringer Feb 04 '13 at 09:49
  • im using postgreSQL 8.0 and i am executing my statements in console. – Grzzzzzzzzzzzzz Feb 04 '13 at 09:53
  • Closevoted as incomplete. Please see http://stackoverflow.com/questions/how-to-ask and http://stackoverflow.com/tags/postgresql/info for details. Consider editing your question to include relevant detail, or deleting it and writing a more complete one. Also, PostgreSQL 8.0 is amazingly obsolete and totally unsupported. – Craig Ringer Feb 04 '13 at 10:02
  • Stop using 8.0 (especially if you are on Windows) and upgrade to a supported version ***now***. –  Feb 04 '13 at 10:07
  • With UTF-8, for Windows console you must use `chcp 65001` – mvp Feb 04 '13 at 10:32

1 Answers1

2

As you've indicated this is on the console, you must first check your console encoding before starting psql.

See Unicode characters in Windows command line - how? for details of how to do this in windows.

This must be done because even if you do get psql to read / write in UTF8 your console won't necessarily understand the characters and will not display them correctly.

Once you've confirmed that your console can accept UTF-8 Encoding then makesure that psql has picked this encoding up:

show client_encoding;
 client_encoding
-----------------
 UTF8
(1 row)

If that doesn't show UTF-8 then you can use:

set client_encoding = UTF8;

As a general rule; if your program is expecting to use UTF8 then there is no harm in setting the client encoding blindly (without checking what it is to start with).

http://www.postgresql.org/docs/current/static/multibyte.html

Note: The above link is for the current version. As the OP has asked for version 8.0, here is the link for the 8.0 manual:

See http://www.postgresql.org/docs/8.0/static/multibyte.html

Community
  • 1
  • 1
Philip Couling
  • 13,581
  • 5
  • 53
  • 85