dbTalk Databases Forums  

[SQL] How to html-decode a html-encoded field

mailing.database.pgsql-sql mailing.database.pgsql-sql


Discuss [SQL] How to html-decode a html-encoded field in the mailing.database.pgsql-sql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
JORGE MALDONADO
 
Posts: n/a

Default [SQL] How to html-decode a html-encoded field - 04-10-2012 , 10:59 AM






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

Reply With Quote
  #2  
Old   
Pavel Stehule
 
Posts: n/a

Default Re: [SQL] How to html-decode a html-encoded field - 04-10-2012 , 11:01 AM






Hello

see http://postgres.cz/wiki/PostgreSQL_S..._of_url _code

Regards

Pavel Stehule

2012/4/10 JORGE MALDONADO <jorgemal1960 (AT) gmail (DOT) com>:
Quote:
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
--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #3  
Old   
Jasen Betts
 
Posts: n/a

Default Re: [SQL] How to html-decode a html-encoded field - 04-12-2012 , 07:26 AM



On 2012-04-10, JORGE MALDONADO <jorgemal1960 (AT) gmail (DOT) com> wrote:
Quote:
--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&amp;witch'),('to&#x61;ster'))
select
column1 as input ,
(xpath('/z/text()', ('<z>'|| column1 ||'</z>')::xml))[1] as output
from sample

--
⚂⚃ 100% natural


--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.