From: | John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com> |
---|---|
To: | Stephen Cook <sclists(at)gmail(dot)com> |
Cc: | PostgreSQL - general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Equivalent of PHP "hex2bin()" |
Date: | 2014-12-19 20:47:59 |
Message-ID: | CAAJSdjiiWLjX-Y50KvDb2DGQjfXxnsr_C_u4R2e2BhzG1UErTg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
to_hex() takes in integer or bigint and returns a hexadecimal string
equivalent. But there is also, perhaps better, encode() and decode() which
convert string to either base64, hex, or "escape" codes.
http://www.postgresql.org/docs/9.3/static/functions-string.html
On Fri, Dec 19, 2014 at 2:38 PM, Stephen Cook <sclists(at)gmail(dot)com> wrote:
>
> PHP has functions "bin2hex()" and "hex2bin()", and I have to deal with
> the results in PostgreSQL.
>
> These functions "Returns an ASCII string containing the hexadecimal
> representation of str. The conversion is done byte-wise with the
> high-nibble first" and "Decodes a hexadecimally encoded binary string".
> Basically you can take binary data and each byte becomes two hexadecimal
> characters.
>
> Is there anything in PostgreSQL that can do this already? I'm sure I can
> work it out but it can't hurt to ask first.
>
> -- Stephen
>
>
--
While a transcendent vocabulary is laudable, one must be eternally careful
so that the calculated objective of communication does not become ensconced
in obscurity. In other words, eschew obfuscation.
111,111,111 x 111,111,111 = 12,345,678,987,654,321
Maranatha! <><
John McKown
From | Date | Subject | |
---|---|---|---|
Next Message | Scot Kreienkamp | 2014-12-19 21:33:49 | Re: Blocking access by remote users for a specific time period |
Previous Message | Stephen Cook | 2014-12-19 20:38:03 | Equivalent of PHP "hex2bin()" |