From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | agostonbejo <bejoag1(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to have ant's <sql> task insert special chars appropriately? |
Date: | 2009-09-23 09:29:02 |
Message-ID: | 4AB9EA5E.40307@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
agostonbejo wrote:
>
> Hi!
>
> What I'm trying to do is to insert some data from a sql file into a postgres
> DB by calling the <sql> ant task. My problem is that I can't get special
> characters (even if they can be represented by the standard ASCII charset,
> such as ä, ö, ü, é, etc.) to be inserted correctly.
Those aren't ASCII.
> When I check the DB with a DB browser such as Squirrel or pgAdmin, after
> running the <sql> task they can only see question marks where these
> characters are supposed to be. So does the actual web application using the
> DB. (The web app can store and read such special characters seamlessly,
> though. It's also OK if I enter some of them by hand with the DB browsers
> mentioned above.)
[snip]
> Does anyone have any idea how to get those special characters loaded into
> the DB from a pre-written sql file (possibly with the ant <sql> task)?
There are three places you need to get this right:
1. The database encoding
2. The client encoding
3. The encoding of the contents of the .sql file
Now, since the database is UTF8 that means it can accept the entire
range of unicode characters, including all ISO-8859-1.
PostgreSQL can automatically convert from ISO-8859-1 to UTF-8 for you,
so it doesn't matter which you have in your .sql file.
What *does* matter is that you know what encoding your .sql file is
using and that you set the client encoding appropriately.
Since you're using Java, it's probably simplest just to use UTF-8 all
the way through. Crucially, make sure you know what the character-set of
the .sql file is - any good text editor should be able to tell you / set
this.
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | J. Roeleveld | 2009-09-23 09:35:03 | Re: How to have ant's <sql> task insert special chars appropriately? |
Previous Message | Abraham, Danny | 2009-09-23 08:33:15 | Re: PL/PG SQL: select count(*) into <var> from <tab> where <cond> - does not compute the where cond |