Problems with UTF8 in postgres

Asked

Viewed 3,959 times

0

I have a JSF project with JPA, Postgres 9 bank The information with lighting is being recorded with accent problems.

Ex:
ã records as At£
Shark records as Tubara

The Bank is with:

Ecoding = UTF8
Collation = Portuguese_brasil, 1252
Character Type = Portuguese_brasil, 1252

All xhttp pages with:

<h:head>
   <f:facet name="first">
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
       <meta name="viewport" content="width=device-width, initial-scale=1"/>
   </f:facet>
   ... 

Obs:
If I write directly to the bank, it records correctly and comes correct to the page, but when I re-record the problem.

The reverse also happens, I type correctly on the page but when write writes with problem.

  • Files were saved in UTF8 without GOOD? It is an ajax upload?

  • Sorry I didn’t understand the GOOD. I believe they were saved yes in UTF8. As for loading ajax time yes time no.

  • Have sublimeText or Notepad++ installed? Open your "java" files on it and in the footer should appear the encoding that were saved.... Another doubt, the problem only occurs at the moment ajax or at another time or both?

  • The problem occurs at the time of recording. Persistence. Os . java were saved in UTF8 (seen by Notepad++)

  • 1

    Marcelo note that UTF8 is different from UTF8 without BOM, but ok, let’s move on... many things seem to be in the recording, but the problem is usually in the same display (rarely is in the recording unless you have done something amazing rsrs). There is an example with mysql that seemed to be the same situation, the user believed to be at the time of recording, but we were able to detect that the failure was totally in reading or encoding the files. If you can give more details we can determine the real origin of the problem.

  • I can yes what you need?

  • Marcelo is a little complicated to explain what is necessary to understand the problem, however a reading on this link may help to understand what can help make your problem clearer: http://answall.com/help/mcve. Creating a good example of the problem can be a good way to explain how the process occurs until it fails.

  • Blz I’m going to take a look. Only complementing the UTF-8 is without GOOD [now I got the GOOD one :) ]

Show 3 more comments

2 answers

1

Assuming the coding of your DATABASE and your server are using the UTF8 as ENCODING, I suggest checking with your client.

Postgresql has an environment variable called CLIENT_ENCODING which is responsible for controlling the encoding used by the client that is connected to the database server.

With this variable properly configured, the server is able to convert client/server and server/client encodings appropriately, otherwise the reported case will happen.

With the command SHOW, we can examine how this variable is configured:

SHOW CLIENT_ENCODING;

With the command SET, we can change its value, for example:

SET CLIENT_ENCODING = 'UTF8';

Heed: Since the data were recorded with this type of error, it is practically impossible to correct them in an orthodox way.

References:

Portuguese (V8.0): http://pgdocptbr.sourceforge.net/pg80/multibyte.html

English (V9.2): https://www.postgresql.org/docs/9.2/static/multibyte.html

I hope I’ve helped!

  • It wasn’t that. .

  • I’m checking but I haven’t found the problem and how best to describe it.

0

In the glassfish-web.xml file that is in the WEB-INF folder add:

<glassfish-web-app error-url="">
    <parameter-encoding default-charset="UTF-8"/>
    ...
</glassfish-web-app>
  • I don’t have that right.

Browser other questions tagged

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