byte order mark - How to convert PostgreSQL escape bytea to hex bytea? -


I got to check a fixed BOM in the PostgreSQL text column. What I really want to do, should be something more normal, like something

  select decode (copy (text column, '\\', '\\\'), 'escape' ) From the table;  

The result of a UTF 8 BOM is:

  \ 357 \ 273 \ 277  

Which of the physical bitea And can be converted by switching the output of bytes in pgadmin:

  update pg_settings set = setting = 'hex' where name = 'bytea_output'; Select '\ 357 \ 273 \ 277': Bitia  

:

  \ xefbbbf  

I What I would like to do is find results as a query, such as

  update pg_settings set setting = 'hex' where name = 'bytea_output'; Select the decode (change the text column, '\\', '\\\' ',' Escape ') from tableCYY;  

But this does not work, the result is empty, possibly because decode hex can not control the output.

If the end objective is to get the textColumn Hexadecimal representation of bytes, it can be done with:

  SELECT encode (convert_to (textColumn, 'UTF-8'), 'hex') from tableYY;  

It does not depend on bytea_output . BTW, this setting plays a role only in the last step of a query, when the result is column type bytea and the client has to return it in the text format (which is the most common case, and What pgAdmin does). It is a matter of representation, the representation of the actual value (the series of bytes) is the same.

In the above query, the result type is text , so it is irrelevant anyway.

I think your query can not work with the decode (..., 'escape') because logic should be encoded in escape format and It is not, per comments it is normal XML string.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -