Postgres.pgadmin. How to configure encoding? - postgresql

I have installed postgreSQL.
I use pgAdminIII as admin panel.
I am trying to watch tables content and see following:
How to avoid encoding problem?

For a UTF8 database, pgAdmin should always display strings correctly. The most likely explanation is that the data itself is incorrect.
This generally happens when a client application sends data in a format which doesn't match its client_encoding setting. If this is the case, setting client_encoding correctly would prevent this from happening (provided the client application's code page is supported by Postgres). This wouldn't fix the existing data, but it might be possible to repair it with the convert function.

Related

Change charset view data Heidisql

I started using HeidiSQL to access Postgres, where the base is under WIN1252.
When opening a table, where it has data like ~ç and other special characters, it is not showing correctly.
I couldn't find where to change the display configuration.

Database encoding in PostgreSQL

I have recently started using PostgreSQL for creating/updating existing SQL databases. Being rather new in this I came across an issue of selecting correct encoding type while creating new database. UTF-8 (default) did not work for me as data to be included is of various languages (English, Chinese, Japanese, Russia etc) as well as includes symbolic characters.
Question: What is the right database encoding type to satisfy my needs.
Any help is highly appreciated.
There are four different encoding settings at play here:
The server side encoding for the database
The client_encoding that the PostgreSQL client announces to the PostgreSQL server. The PostgreSQL server assumes that text coming from the client is in client_encoding and converts it to the server encoding.
The operating system default encoding. This is the default client_encoding set by psql if you don't provide a different one. Other client drivers might have different defaults; eg PgJDBC always uses utf-8.
The encoding of any files or text being sent via the client driver. This is usually the OS default encoding, but it might be a different one - for example, your OS might be set to use utf-8 by default, but you might be trying to COPY some CSV content that was saved as latin-1.
You almost always want the server encoding set to utf-8. It's the rest that you need to change depending on what's appropriate for your situation. You would have to give more detail (exact error messages, file contents, etc) to be able to get help with the details.

PostgreSQL Locale Language

I'm running Debian 3.2 w/ PostgreSQL 9.2 installed. A co-worker of mine initialized the database cluster with japanese. So now, every single database created with createdb, no matter who the user is, is now instantiated with japanese as it's language.
I cannot find a way to reset the language back to english w/o having to run initdb again on a new cluster. I really don't want to do this as there is a lot of data that can't afford to go down.
From what I've read, the database cluster is set with japanese when the command with these flags are called initdb -D /place/for/data --locale=ja_JP. However when I create the same cluster and then use createdb to create a new database, the language of the error messages are in English. In my co-workers cluster, the error messages from this scenario would produce japanese error messages.
Can someone help me understand how the locales work in PostgreSQL 9.2? And what would be the way to change the cluster back into English?
You can't fully change the cluster back into English without a full dump and reload.
In general the postmaster will emit messages in the language and encoding the database cluster was initdb'd in. Sessions on individual databases will emit messages in the language and encoding that database was created in, which may not be the same as the cluster defaults.
This can lead to logs in mixed languages and mixed text encodings, which is really pretty ugly. Despite repeated discussions on the mailing lists we've never come to an agreement on how to solve that - it's more complicated than it looks.
Because each session logs in its own locale settings, what you can do is CREATE DATABASE ... with the appropriate LC_CTYPE, ENCODING, LC_COLLATE, etc settings per the CREATE DATABASE manual page. You may have to specify TEMPLATE template0 for this to succeed. This will result in newly created databases being in the desired language and encoding; you can then dump each old DB into a corresponding new one, rename the old one, and rename the new one into the old one's place. The old one can be dropped when you're comfortable all's well.
Postmaster-level messages will still be in Japanese. I don't think there's a way around that without a re-initdb. Worse, if it's not jp_JP.UTF-8 but a a different encoding, you might have mixed encodings in your log files, something that can quite upset logfile processors etc.

refused database connection causes encoding error

I have a postgreSQL Server with some databases. Every user can only connect to certain databases.
So far so good. I wanted to test if everthing worked, so i used pgAdmin III to log in with a restricted user. when i try to connect to a database the user has no connection rights to, something seems to happen to the logfile!
it can't be read by the server-status window anymore. All i get are a lot of messages about invalid Byte-sequences for encoding utf8.
The only way of stopping those messages windows is to kill the programm and force postgre to create a new logfile.
can anyone explain to me why that happens and how i can stop it???
OK, I think the problem is the "ü" in "für". The error message seems to be complaining about a character code 0xfc which in latin1 (and similar) is lower case u with umlaut.
Messages sent back via a database connection should be translated to the client encoding. However, the log-file contains output from a variety of sources and according to this there were issues fairly recently (2012):
It's a known issue, I'm afraid. The PostgreSQL postmaster logs in the
system locale, and the PostgreSQL backends log in whatever encoding
their database is in. They all write to the same log file, producing a
log file full of mixed encoding data that'll choke many text editors.
So - I'm guessing your system locale is 8859-1 (or -15 perhaps) whereas pg-admin is expecting UTF-8. Short-term, you could set the system encoding to UTF-8, longer term drop a bug report over to the pgadmin team - one error message is helpful, after that it should probably just put hexcodes in the text or some such.

How to export data with Arabic characters

I had an application that used a Sybase ASA 8 database. However, the application is not working anymore and the vendor went out of business.
Therefore, I've been trying to extract the data from the database, which has Arabic characters. When I connect to the database and display the contents, Arabic characters do not display correctly; instead, it looks something like ÇáÏãÇã.
Which is incorrect.
I tried to export the data to a text file. Same result. Tried to save the text file with UTF-8 encoding, but to no avail.
I have no idea what collation the tables are set to. Is there a way to export the data correctly, or convert it to the correct encoding?
the problem was solved by exporting the data from the database using "Windows-1252" encoding, and then importing it to other applications with "Windows-1256" encoding.
When you connect to the database, use the CHARSET=UTF-8 connection parameter. That will tell the server to convert the data to UTF-8 before sending it to the client application. Then you can save the data from the client to a file.
This, of course, is assuming that the data was saved with the correct character set to begin with. If it wasn't, you may be out of luck.