Em 02/02/11, Rogério Bassete<[email protected]> escreveu:
> Pessoal,
>
> Porque que quando faça uma conversão de tipo no PostgreSQL ele me retorna
> SCAPES ao invés do caracter desejado, veja:
>
> No postgresql 8.2:
>
> postgres=# select convert('ROGÉRIO','LATIN1');
> convert
> ----------
> ROGÉRIO
> (1 registro)
>
> No postgresql 9.0:
>
> postgres=# select convert_to('ROGÉRIO','LATIN1');
>    convert_to
> ----------------
> ROG\303\211RIO
> (1 registro)
>
> Ambas as bases de dados são ENCODING LATIN1.
>
> Ambos os servidores são LINUX.
>


Repare na definição da função CONVERT na versões 8.2 e 9.0,
particularmente no tipo do resultado retornado pela função:
8.2:
convert(string using conversion_name)
Return Type:    text
Change encoding using specified conversion name. Conversions can be
defined by CREATE CONVERSION. Also there are some pre-defined
conversion names. See Table 9-7 for available conversion names.
Ex:     convert('PostgreSQL' using iso_8859_1_to_utf8)
        'PostgreSQL' in UTF8 (Unicode, 8-bit) encoding
http://www.postgresql.org/docs/8.2/interactive/functions-string.html

9.0:
convert(string bytea, src_encoding name, dest_encoding name)
Return Type:    bytea
Convert string to dest_encoding. The original encoding is specified by
src_encoding. The string must be valid in this encoding. Conversions
can be defined by CREATE CONVERSION. Also there are some predefined
conversions. See Table 9-7 for available conversions.
Ex.:    convert('text_in_utf8', 'UTF8', 'LATIN1')
        text_in_utf8 represented in Latin-1 encoding (ISO 8859-1)
http://www.postgresql.org/docs/current/interactive/functions-string.html

Osvaldo
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a