Thread: Encoding Conversion

Encoding Conversion

From
Wilton Wonrath
Date:
Hi,
 
When I´m doing a conversion PostgreSQL returns SCAPES to me besides the desire caracter. Why ?
 
Using Postgresql 8.2:
 
SELECT CONVERT('Rejeição: Duplicidade de NF-e, com diferença na Chave de Acesso [35110100608804000178550010001009471840996034]','UTF8','LATIN1')
 
Result: "Rejeição: Duplicidade de NF-e, com diferença na Chave de Acesso [35110100608804000178550010001009471840996034]"
 
Using Postgresql 9.0:
 
SELECT CONVERT('Rejeição: Duplicidade de NF-e, com diferença na Chave de Acesso [35110100608804000178550010001009471840996034]','UTF8','LATIN1')
 
Result: "Rejei\347\343o: Duplicidade de NF-e, com diferen\347a na Chave de Acesso [35110100608804000178550010001009471840996034]"

Both databases are "encoding latin1".
Both servers are "Linux".

Regards,

Wilton Ruffato Wonrath

 

Re: Encoding Conversion

From
Tom Lane
Date:
Wilton Wonrath <wrwonrath@yahoo.com.br> writes:
> When I�m doing a conversion PostgreSQL returns SCAPES to me besides the desire
> caracter. Why ?

Somewhere between 8.2 and 9.0 convert() was redefined to take and return
bytea, not text, to reflect the fact that the data it deals in isn't
necessarily encoded in the database's character encoding.  This was part
of a general tightening up to ensure that text that ought to be in the
database encoding really is.

There are some related functions now that convert between text (assumed
to be in the database encoding) and bytea strings in a specified
encoding.  You probably want to switch over to using those.

            regards, tom lane