RE: [JDBC] Re: Reading £ character from DB is displaying œ character

From: "Hudson, Derrick" <dhudson(at)redcom(dot)com>
To: "'saisantoshi'" <mr(at)starsborn(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: RE: [JDBC] Re: Reading £ character from DB is displaying œ character
Date: 2013-09-24 16:05:04
Message-ID: 401084E5E73F4241A44F3C9E6FD79428A70C62C7@exch-01
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


How do you determine that you "get gibberish characters"? Are you printing the string, or inspecting the individual characters in memory using a debugger? The gibberish is probably the result of the way the text is displayed, not a problem with the database or the JDBC. You need to correctly encode the string as bytes before sending it to System.out. "correctly" depends on the encoding expected by your terminal (cmd.exe, the console of an IDE, etc.).

This answer on StackOverflow should be helpful; it is equally applicable to the original question of JSON as it is to your question of JDBC.

http://stackoverflow.com/questions/11868022/unicode-characters-appearing-as-question-marks-in-java-json-parsing/11868911#11868911

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org [mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of saisantoshi
Sent: Tuesday, September 24, 2013 12:52 AM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] Re: Reading £ character from DB is displaying œ character

Here is what I get:

testdb=> set client_encoding='DOS437';
ERROR: invalid value for parameter "client_encoding": "DOS437"
testdb=> set client_encoding='CP437';
ERROR: invalid value for parameter "client_encoding": "CP437"

The other question I have is if I am setting the server_encoding/client_encodng to UTF8, then saving the £ character into DB should save £ and be able to see the same in the table. I am still not clear as to why it gets gibbersh characters... its much confusing as to believe if it saved the right characters. Not sure what's missing peice here??

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jim Garrison 2013-09-24 17:54:02 Troubleshooting query performance issues
Previous Message saisantoshi 2013-09-24 04:52:23 Re: Reading £ character from DB is displaying œ character