ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 27th, 2005, 09:44 AM
jcvega247 jcvega247 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Chicago, IL
Posts: 42 jcvega247 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 3 m 18 sec
Reputation Power: 6
replace function with ascii

Hello,
I cant seem to find documentation on this type of error. The trouble I am having is replacing an ascii character with something else.

For example,
<cfset some_text="foo & bar">
<cfoutput>#replace(some_text, "&", "+", "All")#</cfoutput>

Outputs
foo & bar

And not the desired
foo + bar

Removing the quotes around & gives a missing argument error:

"When using named parameters to a function, every parameter must have a name."

I use the ampersand as an example, I know that I could simply type the ampersand in, but the actual char I am using in my code is &#149, which isn't on the keyboard.

Thanks in advance

Last edited by jcvega247 : May 27th, 2005 at 09:47 AM. Reason: Clarfied what removing quotes error is

Reply With Quote
  #2  
Old May 27th, 2005, 10:25 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,661 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 14 h 23 m 22 sec
Reputation Power: 53
Not sure if there is a way to do it with ascii codes, but what about character codes?

#replace(some_text, chr( 38 ), "+", "All")#

You can see the whole list at
http://www.lookuptables.com/
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old May 27th, 2005, 11:22 AM
jcvega247 jcvega247 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Chicago, IL
Posts: 42 jcvega247 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 3 m 18 sec
Reputation Power: 6
Thanks, that works fine. I had some trouble finding the chr value for &#149, but with the help of a more seasoned programmer he found it to be chr(8226) using a cfloop and char. Go figure. Thanks again for your much needed direction!

Reply With Quote
  #4  
Old May 31st, 2005, 05:43 AM
Faunus Faunus is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Manchester, UK
Posts: 129 Faunus User rank is Sergeant (500 - 2000 Reputation Level)Faunus User rank is Sergeant (500 - 2000 Reputation Level)Faunus User rank is Sergeant (500 - 2000 Reputation Level)Faunus User rank is Sergeant (500 - 2000 Reputation Level)Faunus User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 13 h 10 m 32 sec
Reputation Power: 10
<cfset some_text="foo & bar">
<cfoutput>#replace(some_text, "&", "+", "All")#</cfoutput>

^^ As far as I know, the reason that wasn't working was because the & isn't processed at server side, and the replace function was looking for an unprocessed (literal) "&" string. Would have worked if used:

<cfset some_text="foo & bar">

Kiteless provided the solution, I thought I might explain the failure ;P

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > replace function with ascii


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway