Jump to content
vchris

Escaping Comma

Recommended Posts

I have a list and one of my list entries has a comma. How do I escape a comma in a list?Example of the entry:<cfset sectorList = ListAppend(sectorList, "iron,_steel_and_limenite_smelting") />

Share this post


Link to post
Share on other sites
<cfset sectorList = ListAppend(sectorList, "iron#chr(44)#_steel_and_limenite_smelting") />

That should do it.Use this code to get the numeric value of the chr() function you are looking for:

<cfloop index="x" from="1" to="50"><cfoutput>#x# = #Chr(x)#<br /></cfoutput></cfloop>

Increase the "to" value here to something like 5000 or 50000 to get even more characters.:)

Share this post


Link to post
Share on other sites

As I think about it more, that might not work either . . . I'd have to look into this a little more if it doesn't.Are you able to replace it with some other value that you could then translate whenever this information is retrieved again?

Share this post


Link to post
Share on other sites

Yeah I just tried it out and it doesn't work. See for yourself:<cfset myList = "john#chr(44)# test" /><cfloop index="i" list="#myList#"> <cfoutput>#i#</cfoutput></cfloop>Could I change the default delimiter to something else?EDIT:I got it! I replaced the default delimiter by a !. It works perfectly.

Share this post


Link to post
Share on other sites

oh oh got another problem.See I have this drop down that is populated with this coldfusion list I created. Then when a selection is made a list of links appears underneath the drop down that the user can click on to go view a certain document.So I have:<cfset sectorList = ListAppend(sectorList, "iron,_steel_and_limenite_smelting","!") /><cfset iron,_steel_and_limenite_smelting = '<a href="##">link 1</a>,<a href="##">link 2</a>' />but the comma is not accepted in a variable name. Basically I have the drop down option value equal to the coldfusion variable. All the option in my drop down have a list of their own links. I'm not sure if this is the best way to do this but I thought it was simpler than arrays and easier to update. If you have a better way of doing this let me know.

Share this post


Link to post
Share on other sites

Could you use the position in the array as the value instead of the actual value of the array item?

Share this post


Link to post
Share on other sites

These are lists not arrays.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×