dans.blog


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

ColdFusion TechNote: Recommended supported configurations for ColdFusion MX 6.1 and 7.0 Server

Adobe has released a new TechNote regarding Recommended supported configurations for ColdFusion MX 6.1 and 7.0 Server. This is probably a good document to have handy whenever you set up a clean install of ColdFusion. Hopefully they'll continue to modify this document as patches/upgrades are released.


Calculating the visual length of a string

Sorry I haven't blogged in a while, but I've been very busy working on a project. Part of the project requires that I convert HTML to formatted plain text. On the very surface, this may seem simple (just use a RegEx to remove the HTML,) but the key word in that first sentence was "formatted."

One of the many issues I've run into, is that none of the built-in ColdFusion string manipulation functions account for the "visual" length of a string. Since one of the things I needed to do was wrap text after XX number of visual characters; I needed a function that, unlike the standard len() function, would return the length of a string as it would appear on the screen. This means I have to take into account how many "spaces" a tab would occupy on the screen.

My first attempt was simply to count every tab character (chr(9)) as 8 spaces. While this number assured I would never go past the right edge of the content, it wasn't very accurate (as a tab can very between 1 space to 8 spaces in Windows.) I quickly started running into problems when I realized that for some functionality (like centering text,) I'd really need an accurate account of the total number of visual spaces a string was occupying.

more…