Question

I have a UTF8 encoding database. I am using ECPG - PROGRAM C.

When I get data recordset with EXEC SQL

 EXEC SQL DECLARE cur_myTable CURSOR FOR
     SELECT code,
            label
     INTO  :hv_cod,
           :hv_label
     FROM  myTable

but I print data in the pgc file,

printf("\n libellé => %s", :hv_label ), I get:

I get :

libellé => télé.

Is it possible to UTF8 decode a host variable to ISO-8859-1 in a program C ? Is it possible to say in the .pgc file : Postgres I want UTF8-decode values ?

Thanks

Was it helpful?

Solution

Is it possible to UTF8 decode a host variable to ISO-8859-1 in a program C ?

Sure, lots of libraries do it. Look at libiconv for example.

Is it possible to say in the .pgc file : Postgres I want UTF8-decode values ?

Trivially. Set client_encoding to iso-8859-1 or whatever your local encoding is. You can do this with libpq functions; ecpg may have its own equivalents, not sure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top