dans.blog


The miscellaneous ramblings and thoughts of Dan G. Switzer, II

CFMX: urlDecode() function uses default URL scope charset to decode strings...

If you're getting an Error casting an object of type to an incompatible type message while when using CFMX's urlDecode() function, this is because you're using the wrong charset.

I was getting this error trying to parse some data coming from an XHTML document. Turns out the urlDecode() uses the charset of the URL scope as the default charset to use when decoding a string. Since the charset of the text in my XML document was different than that of my URL scope, I was getting the error. The message isn't very descriptive to the problem, so I spent time trying to cast the string using javaCast() function.

See the urlDecode() documentation for more information.


CFMX UDF: Parsing a URI into a struct...

Ever needed to parse a qualified URI to examine a URL for specific information? I'm working on some code that needs to examine links in a document and extract information about the links.

To make sure I was doing things by the spec, I made sure to check out RFC2396. Fortunately, the RFC has a nice little regular expression for breaking a URI into it's core pieces: scheme, authority, path, query and fragment.

However, those core portions are still pretty broad. The authority can include user info, domain and port information. The path can include embedded parameters inside each segment. So, I took the core regular expression to break up a URI and then I do further parsing on the authority and path portions of the URI.

more…