Entries Tagged as "CFML"

Decoding a \unicode-escaped string in CFML

I needed to incorporate a news feed from yammer.com, which was pretty easy using their API. The return format is JSON, so all looked great. Except for the "rich text" they sent back:

Unicode escapes example cfdump

As you can see, there are a lot of "\u00.." occurences in the rich text. I searched Google for a standard CFML solution to convert these character sequences, but found nothing for CFML. So I wrote the following function, which tries to convert the string as fast as possible:

<cffunction name="unicodeEscape" returntype="string" output="no">
<cfargument name="s" type="string"/>
<!--- If no unicode-escapes present in the string: return --->
<cfif not find('\u', arguments.s)>
<cfreturn arguments.s />
<!--- If % is present in the string: url-encode it. Otherwise, urlDecode would choke on it --->
<cfif find('%', arguments.s)>
<cfset arguments.s = replace(arguments.s, '%', urlEncodedFormat('%'), 'all') />
<!--- Ascii characters (\u0000 - \u00FF) can be translated as %00-%FF --->
<cfset arguments.s = replace(arguments.s, "\u00", "%", "all") />
<!--- Higher characters (\u0100 - \uFFFF) can be translated as %01%00 - %FF%FF.
Only do this regex if there is something to replace. --->
<cfif find('\u', arguments.s)>
<cfset arguments.s = rereplace(arguments.s, "\u([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])", "%\1%\2", "all") />
<cfreturn urldecode(arguments.s) />

If there is a built-in way in CFML to decode unicode-escapes, then please leave a comment. I'd be happy to learn :)


Dutch CFUG networking event on March 22, 2013

I recently joined the CFUG-NL team, which had been a bit silent for the last few years. To start off, and hear about your ideas for upcoming CFUG meetings, we would like to invite you all to a networking event on March 22, 2013 in Utrecht.

Please see www.cfugnl.nl for full details, and don't forget to register. See you at Cafe Olivier!


No Comments

How to upgrade from Railo 3.* to Railo 4

Upgrading your existing Railo 3 installation to Railo 4 is really easy! No need to re-install Railo or anything, just copy-paste some jar files...

No Comments

My view on CFCamp 2012

I did my first conference presentation here at CFcamp 2012. It worked out great, and got some good feedback. I actually can't wait to do another one! Hopefully, you'll be hearing from me at CF.Objective() or Scotch on the Rocks (June 2013!) soon.

So, CFcamp. It is not a German conference. It is a very international one, with speakers from France, Germany, America, Scotland, Switzerland, Belgium, England, etcetera. All presentations were in English, flyers and programs in English, so easily accessible for a Dutchie like me.

The venue was the StadtHalle Germering,

No Comments

Presenting Railo Extension Builder!

At CFcamp 2012, me and Mark Drew did a presentation about Railo extensions, and the Railo Extension Builder. Right there, we released the first public version of Railo Extension Builder.
In case you weren't there, this blog post is a short recap of the presentation. The original slides can be found on slideshare.