|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 •, 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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Thanks, that works fine. I had some trouble finding the chr value for •, 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!
|
|
#4
|
|||
|
|||
|
<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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > replace function with ascii |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|