Unix Technical Forum

Re: Ampersands in the output...

This is a discussion on Re: Ampersands in the output... within the pgsql Novice forums, part of the PostgreSQL category; --> Thanks, Mitch. Yes, you're right, I can definitely do it in the calling servlet, but I was wondering if ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 08:20 PM
Schuhmacher, Bret
 
Posts: n/a
Default Re: Ampersands in the output...

Thanks, Mitch. Yes, you're right, I can definitely do it in the calling
servlet, but I was wondering if there's an easy way to do it in
Postgres. I'll take care of it in Java, then :-).

Rgds,

Bret

> -----Original Message-----
> From: Mitch Pirtle [mailto:mitch.pirtle@gmail.com]
> Sent: Wednesday, January 12, 2005 7:50 PM
> To: Schuhmacher, Bret
> Cc: pgsql-novice@postgresql.org
> Subject: Re: [NOVICE] Ampersands in the output...
>
> Hi Bret,
>
> That sounds most likely served best at the application layer
> - for example, if your application is written in PHP, you can
> use the PHP
> function:
>
> http://us3.php.net/htmlentities
>
> You can also use regular expressions or PHP's str_replace to
> just replace all instances of '&' with '&'.
>
> Pretty sure other languages have their own methods as well.
>
> -- Mitch
>
> On Wed, 12 Jan 2005 16:22:41 -0800, Schuhmacher, Bret
> <Bret.Schuhmacher@aspect.com> wrote:
> > I'm using postgres to return business names via a function. In the
> > function I "xml-ify" the output by taking the name and wrap it with
> > start/end tags, as in "<name>name</name>" (there's a lot

> more to this
> > and I'm simplifying greatly). However, the problem is that some of
> > the names have "&" in them, like "Joes Bar & Grill", which really
> > should be escaped in XML.
> >
> > Any ideas how to escape those things before they get to the

> recipient
> > (i.e. my application, IE, Mozilla, etc.)? Is there a built-in
> > function or something I could make use of? I suppose I

> could write a
> > little more code in my function to look in the field and

> try to do a
> > string replace or something, but is that the most efficient method?
> >
> > Thanks in advance! :-)
> >
> > Bret
> >
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to

> majordomo@postgresql.org
> >

>


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 08:20 PM
Jeff Eckermann
 
Posts: n/a
Default Re: Ampersands in the output...

There is always pl/php or pl/java, if you really want
to put the code in the backend.

--- "Schuhmacher, Bret" <Bret.Schuhmacher@Aspect.com>
wrote:

> Thanks, Mitch. Yes, you're right, I can definitely
> do it in the calling
> servlet, but I was wondering if there's an easy way
> to do it in
> Postgres. I'll take care of it in Java, then :-).
>
> Rgds,
>
> Bret
>
> > -----Original Message-----
> > From: Mitch Pirtle [mailto:mitch.pirtle@gmail.com]

>
> > Sent: Wednesday, January 12, 2005 7:50 PM
> > To: Schuhmacher, Bret
> > Cc: pgsql-novice@postgresql.org
> > Subject: Re: [NOVICE] Ampersands in the output...
> >
> > Hi Bret,
> >
> > That sounds most likely served best at the

> application layer
> > - for example, if your application is written in

> PHP, you can
> > use the PHP
> > function:
> >
> > http://us3.php.net/htmlentities
> >
> > You can also use regular expressions or PHP's

> str_replace to
> > just replace all instances of '&' with '&amp;'.
> >
> > Pretty sure other languages have their own methods

> as well.
> >
> > -- Mitch
> >
> > On Wed, 12 Jan 2005 16:22:41 -0800, Schuhmacher,

> Bret
> > <Bret.Schuhmacher@aspect.com> wrote:
> > > I'm using postgres to return business names via

> a function. In the
> > > function I "xml-ify" the output by taking the

> name and wrap it with
> > > start/end tags, as in "<name>name</name>"

> (there's a lot
> > more to this
> > > and I'm simplifying greatly). However, the

> problem is that some of
> > > the names have "&" in them, like "Joes Bar &

> Grill", which really
> > > should be escaped in XML.
> > >
> > > Any ideas how to escape those things before they

> get to the
> > recipient
> > > (i.e. my application, IE, Mozilla, etc.)? Is

> there a built-in
> > > function or something I could make use of? I

> suppose I
> > could write a
> > > little more code in my function to look in the

> field and
> > try to do a
> > > string replace or something, but is that the

> most efficient method?
> > >
> > > Thanks in advance! :-)
> > >
> > > Bret
> > >
> > > ---------------------------(end of
> > > broadcast)---------------------------
> > > TIP 1: subscribe and unsubscribe commands go to

> > majordomo@postgresql.org
> > >

> >

>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 8: explain analyze is your friend
>





__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:29 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com