From: | "Chris Palmer" <chris(dot)palmer(at)geneed(dot)com> |
---|---|
To: | "Ian Barwick" <barwick(at)gmx(dot)net>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Unicode confusion |
Date: | 2003-05-12 22:35:26 |
Message-ID: | 4DC5F5CE7BA89D40B26FFD9A7982FE254D35C6@mail.geneedinc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ian Barwick writes:
> OK, put it another way: Java is not able to or does not want to print
> the specified Unicode characters (the Yin / Yang symbol and something
> squiggly IIRC) to your STDOUT.
In the example I gave in my first post, stdout was a file. Shouldn't Java just write out bytes without trying to get smart? Especially if stdout is not a tty? But see below.
> This is nothing to do with the
> JDBC connection.
> I presume Java looks at your locale setting, maybe Google knows the
> answer ;-).
Yes, I'm searching now.
> Using a UTF-8 capable terminal (I use mlterm or konsole, no
> idea what options
> there are in Windows) the characters retrieved from Postgres
> and which are now
> in Java's internal Unicode encoding (which one I don't recall) can be
> displayed by converting them into UTF-8.
===
ps = new PrintStream(System.out, true, "UTF-8");
...
// this line might look strange to you if your mailer shows it differently than mine does:
s.executeUpdate("INSERT INTO test (chug) VALUES ('¤ä´©¬O¬°¤FÅý')");
s.executeUpdate("INSERT INTO test (chug) VALUES ('testing')");
s.executeUpdate("INSERT INTO test (chug) VALUES ('\u262f\u0b87')");
...
ps.println(rs.getString("chug"));
===
I'm no Java expert, so if that's not a good way to get UTF-8-encoded output, please let me know. When I try it, I get:
===
> java Noodle > goo
> cat goo
¤ä´©¬O¬°¤FÃ
ý
testing
â¯à®
===
I installed KDE on our Linux machine (the one running Java and Pg) and got the similar results using konsole. (Fwiw I am using PuTTY on Windows to connect to Linux).
===
¤ä´©¬O¬°¤FÃý
testing
â¯à®
===
Note the lack of the newline in the middle of the first result.
In either case, konsole or PuTTY, I am not getting back what I put in (the first s.executeUpdate(...), above).
In psql, the result of "select * from test" looks the same as it does when output by the Noodle Java program.
Fwiw, I do have the encoding of this database set to UNICODE:
===
> psql -p 9000 -l
List of databases
Name | Owner | Encoding
-----------+------------------------+-----------
japanese | GENEEDINC+chris.palmer | EUC_JP
template0 | GENEEDINC+chris.palmer | SQL_ASCII
template1 | GENEEDINC+chris.palmer | SQL_ASCII
test | GENEEDINC+chris.palmer | SQL_ASCII
unicode | GENEEDINC+chris.palmer | UNICODE
===
I am much more confused now than I ever have been. :)
--
Chris Palmer Systems Programmer GeneEd
From | Date | Subject | |
---|---|---|---|
Next Message | Skip Montanaro | 2003-05-12 22:42:12 | Broken upgrade_tips link |
Previous Message | Karsten Hilbert | 2003-05-12 22:31:25 | Re: create db with -E |