How to convert this character to Postgresql?

Asked

Viewed 250 times

2

I am using Delphixe and Postgresql, it happens that I need to insert some characters in the database that are not accepted in LATIN1.

My base is UTF-8, but as the system has been transported since the Delphi6 version, and old base I’m using LATIN1, I can’t just switch from LATIN1 to UTF-8 paw because the Delphi screams from all that is side.

I can enter the normal Pgadmin Data, but when I try to read in Delphi it complains that there is no corresponding character in LATIN1.

The character is like this "α-Chloroprene" and "α,α''Diamine m-xylene"

I’m in a Beak pool

Do you have any suggestions?

Obs.: These are documents to be sent to the eSocial so I have to send them the way they want, if not the refusal... there already saw right

1 answer

2


According to the documentation, Postgresql supports automatic conversion from UTF-8 to LATIN1, simply inform Character set of your client, in the case of the Delphi application.

For this you have some options. If you can change the application, you can set the client_encoding soon after making the connection, so everything will come in LATIN1:

set client_encoding to 'LATIN1';

Another possibility, to avoid any change in the application, you can also change the client_encoding user’s standard:

alter user usuario_latin1 set client encoding to 'LATIN1';

Of course, for this it is better to have a unique user, separate from the one used by clients who understand UTF-8.

  • Nunks, killed at the stake, I was trying to do this with the postgres user and it was not working, I thought it was not possible, as this system is specific and only for this company was using the same postgres user, your post made me open my mind and I decided to create a new user and changed as your tip, gave right, he does not complain and shows the character correctly, breaking this will solve me another problem that gave when the guy copied and pasted text of the word that came with UTF-characters8, thank you very much!

  • Nunks, I tried to put @ before your login but the stack does not let, must have some filter, your login must be reserved word

  • @Marcelo poizé, I don’t know because my nick has some weirdness with the OS, haha. Anyway, we even tend to forget that many Postgresql parameters work at the user level and may well serve to resolve conflicts that would appear if we had to change global options. Glad I could help =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.