pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to html-decode a html-encoded field
3+ messages / 3 participants
[nested] [flat]
* How to html-decode a html-encoded field
@ 2012-04-10 15:59 JORGE MALDONADO <jorgemal1960@gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: JORGE MALDONADO @ 2012-04-10 15:59 UTC (permalink / raw)
To: pgsql-sql
I have a table with a varchar field, such a field is HTML ENCODED. So, for
example, the string "PLAIN WHITE T'S" is saved as "PLAIN WHITE
T''S" (double quotes are not part of the string, I use them for
clarity only). I need to perform a SELECT statement on this table and get
the values HTML DECODED and I wonder if there is a function that I can
include in such a statement for this purpose, for example "SELECT
htmldecode(fld1) FROM table1". I will appreciate anu comments about my
issue.
Respectfully,
Jorge Maldonado
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to html-decode a html-encoded field
@ 2012-04-10 16:01 Pavel Stehule <pavel.stehule@gmail.com>
parent: JORGE MALDONADO <jorgemal1960@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Pavel Stehule @ 2012-04-10 16:01 UTC (permalink / raw)
To: JORGE MALDONADO <jorgemal1960@gmail.com>; +Cc: pgsql-sql
Hello
see http://postgres.cz/wiki/PostgreSQL_SQL_Tricks#Function_for_decoding_of_url_code
Regards
Pavel Stehule
2012/4/10 JORGE MALDONADO <jorgemal1960@gmail.com>:
> I have a table with a varchar field, such a field is HTML ENCODED. So, for
> example, the string "PLAIN WHITE T'S" is saved as "PLAIN WHITE T''S"
> (double quotes are not part of the string, I use them for clarity only). I
> need to perform a SELECT statement on this table and get the values HTML
> DECODED and I wonder if there is a function that I can include in such a
> statement for this purpose, for example "SELECT htmldecode(fld1) FROM
> table1". I will appreciate anu comments about my issue.
>
> Respectfully,
> Jorge Maldonado
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to html-decode a html-encoded field
@ 2012-04-12 12:26 Jasen Betts <jasen@xnet.co.nz>
parent: JORGE MALDONADO <jorgemal1960@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jasen Betts @ 2012-04-12 12:26 UTC (permalink / raw)
To: pgsql-sql
On 2012-04-10, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:
> --000e0ce0d2ee43edb104bd553408
> Content-Type: text/plain; charset=ISO-8859-1
>
> I have a table with a varchar field, such a field is HTML ENCODED. So, for
> example, the string "PLAIN WHITE T'S" is saved as "PLAIN WHITE
> T''S" (double quotes are not part of the string, I use them for
> clarity only). I need to perform a SELECT statement on this table and get
> the values HTML DECODED and I wonder if there is a function that I can
> include in such a statement for this purpose, for example "SELECT
> htmldecode(fld1) FROM table1". I will appreciate anu comments about my
> issue.
if you don't mind gettin an exception or the wrong answer on invalid
input you can abuse xpath thusly:
with sample as ( values ('magic'),('s&witch'),('toaster'))
select
column1 as input ,
(xpath('/z/text()', ('<z>'|| column1 ||'</z>')::xml))[1] as output
from sample
--
⚂⚃ 100% natural
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2012-04-12 12:26 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-04-10 15:59 How to html-decode a html-encoded field JORGE MALDONADO <jorgemal1960@gmail.com>
2012-04-10 16:01 ` Pavel Stehule <pavel.stehule@gmail.com>
2012-04-12 12:26 ` Jasen Betts <jasen@xnet.co.nz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox