How do you determine that you "get gibberish characters"? Are you printing the string, or inspecting the individual
charactersin memory using a debugger? The gibberish is probably the result of the way the text is displayed, not a
problemwith 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
yourquestion 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@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of saisantoshi
Sent: Tuesday, September 24, 2013 12:52 AM
To: pgsql-jdbc@postgresql.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
intoDB 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??