Question : How to convert the encoding of a text in a select statement?

Hello,

I'm trying to execute this sql but it's appearing the error:

ERROR:  invalid byte sequence for encoding "UTF8": 0xc152
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

I know that is because the word "SECRETÁRIA". But, is there some "convert" function to fix that?


Thanks!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
select case 
			when cc.crede = 21 then 
            	'SECRETÁRIA DA EDUCACAO'
            else 
            	'COORDENADOR(A)' end 
       as Cargo, 
       ut.cd_crede,
       ut.nm_sigla as UnidadeTrabalho,
       ic.nr_processo,
       ic.nome,
       ic.dt_ato_nomeacao, 
       ic.dt_doe,
       ic.disciplina
from rh.tb_carencia_concurso cc join rh.tb_importacao_concurso ic on cc.cpf = ic.cpf
                                join util.tb_unidade_trabalho ut on cc.crede = ut.ci_unidade_trabalho

Answer : How to convert the encoding of a text in a select statement?

>>> But your post it's about mysql

While the specifics are about MySQL, the general concept applies to Postgre as well.  Converting between encodings is going to be a manual process, regardless of the database.  Postgre does have some of this wired for you, but you should understand that the limits on translation are inherent in the way language works.  See:

http://www.postgresql.org/docs/8.4/interactive/multibyte.html
http://www.postgresql.org/docs/8.4/interactive/functions-string.html

Collation is not what you want - that is sorting behavior based on the encoding you are using.
Random Solutions  
 
programming4us programming4us