Capitalizer.cfc 1.0

Recently, a client of mine started working on printing up badges for users on their system. As soon as we started testing the system, they complained that the badges looked amateurish.

The problem was that the badges were using information originally entered by the users themselves. Sometimes these users enter their information with caps-lock on. So, "Joe Smith" could come out "JOE SMITH" or even "jOE sMITH". Naturally, both of these look pretty unprofessional on a printed badge.

With more than three thousand users already on the system (and more signing up all the time), it wasn't really practical to fix each entry by hand.

At the same time, these seemed like a problem that I was likely to run into again, so I wanted a general solution that I could use again in the future.

The result is Capitalizer.cfc, the heart of which is Adrian Lynch's TitleCaseList() UDF. The component does require DataMgr, but only to keep the code brief.

The main method of Capitalizer is fixFieldCase(). This method can correct the capitalization for a selected field in a table, using the following arguments:

  • table: The name of the table in which you want to fix the capitalization.
  • field: The field in the table in which you want to fix the capitalization.
  • pkfields: A comma delimited list of the primary key fields in the table.

You can also use Capitalizer to correct the case for a single string. You can pass in any string to the fixCase() method and it will return the string with the capitalization fixed.

Capitalizer watches for words that shouldn't be capitalized (like "and,or,the") and makes sure that they aren't. It also makes sure that directions (NE,SW) are capitalized. It also make sure that "mc" names (like "McWilliams") are capitalized correctly.

Capitalizer.cfc is open source and free for any use. Feel free to try it out. 

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
And that was for the forst time they saw that badges?
# Posted By Alef | 6/11/07 3:41 PM
Alef,

Sorry, I don't understand the question. This made sure that all existing data (and all future) data was capitalized appropriately to look professional on the badges. Does that help?
# Posted By Steve Bryant | 6/11/07 3:47 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.