Thread: How convert UNICODE

How convert UNICODE

From
"lms"
Date:
Hello
I have 2 databases with same table. First database is in UNICODE, second in 
SQL_ASCII.
4 columns from first database I must convert to:(first column)iso8859-1,(second column)iso8859-2,(3-th
column)iso8859-1,(4column)iso8859-5.
 

After it I must save these 4 rows in database in SQL_ASCII.
How can I do it? It can be using libpq,libpgeasy,....

Thx.



Re: How convert UNICODE

From
Drew
Date:
How about pg_dump the data from your old database, then load it into  
your new database which is using UTF8?

Drew

On Nov 17, 2006, at 9:09 AM, lms wrote:

> Hello
> I have 2 databases with same table. First database is in UNICODE,  
> second in
> SQL_ASCII.
>
>  4 columns from first database I must convert to:
>  (first column)iso8859-1,
>  (second column)iso8859-2,
>  (3-th column)iso8859-1,
>  (4 column)iso8859-5.
>
> After it I must save these 4 rows in database in SQL_ASCII.
> How can I do it? It can be using libpq,libpgeasy,....
>
> Thx.
>
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that  
> your
>        message can get through to the mailing list cleanly



Re: How convert UNICODE

From
"lms"
Date:
Hi

New database must be in SQL_ASCII. In old database (UNICODE) are for example 
2 columns. Rows from first column I must convert to ISO_8859_2 and insert it 
to first column in SQL_ASCII database, and rows from second column I must 
convert to IS0_8859_5 and insert to second column in SQL_ASCII database.

On Fri, 17 Nov 2006 13:17:05 -0800, Drew wrote
> How about pg_dump the data from your old database, then load it into 
>  your new database which is using UTF8?
> 
> Drew




Re: How convert UNICODE

From
"lms"
Date:
Hi

Yes, but I must convert diffrent columns to diffrent iso-codes.

With pg_dump I can only dump all columns from database and these all columns 
convert only to one iso-code.

On Fri, 17 Nov 2006 14:11:25 -0500, Travis Whitton wrote 
> There might be better ways, but you could dump the data and use the iconv 
utility. I frequently use it to convert to UTF-8 before loading data. 



Re: How convert UNICODE

From
"lms"
Date:
HiI must copy rows from local database (UNICODE) to remote database SQL_ASCII
(not on local machine) with converting selected columns to iso8859_2 or 
iso_8859_5. Can I make it with COPY?


On Sat, 18 Nov 2006 09:42:14 -0500, Travis Whitton wrote 
> You can use the postgresql COPY command to dump a single column to a file. 
Do this for each column you need to convert. From there, use iconv to 
convert the data. When you're done dumping and converting, use the unix 
paste command to reassemble the data. If you're not on a unix-based 
platform, a simple perl script should do the job. 




Re: How convert UNICODE

From
"lms"
Date:
HelloThanks for help. Iconv is good. Now I use iconv function with libpq.

On Sun, 19 Nov 2006 10:15:53 -0500, Travis Whitton wrote 
> Assuming you're on a Unix based platform: 
> 
> psql> COPY tablename (column1) TO 'column1.csv' WITH CSV; 
> 
> bash> iconv -f UTF-8 -t iso8859_2 column1.csv > iconv-column1.csv 
> 
> psql> COPY tablename (column2) TO ' column2.csv' WITH CSV; 
> 
> bash> iconv -f UTF-8 -t iso8859_5 column2.csv > iconv-column2.csv 
> 
> repeat for each column... 
> 
> bash> paste iconv-column* > newtable.csv