tracker issue : CF-4096966

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] ER for: .titleCase()/titleCase()

| View in Tracker

Status/Resolution/Reason: To Fix//

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 12/07/2015

Components: Language

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win All

Vote Count: 2

.lCase()/lCase() and .uCase()/uCase() are useful. .titleCase()/titleCase() would be as useful.

By default, it should ignore roman numerals and allow them to remain uppercase. By default, it should ignore words like "a" and "an" if they are in the middle of a sentence.

For complete control over the list of words to ignore, an optional ignoreList parameter should be allowed. Example: titleCase(listOfWordsToIgnore)

Tomayto/tomahto scenario: Currently, yesNoFormat() returns Yes or No. So displaying Yes/No vs yes/no in a table column is as simple as appending .lCase() or not. Same simplicity should exist for booleanFormat(). Either 1) booleanFormat() should return True/False or 2) .titleCase()/titleCase() should be implemented (preference is #2).

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4096966

External Customer Info:
External Company:  
External Customer Name: Aaron Neff
External Customer Email:

Attachments:

Comments:

+1 This would be a really nice feature, but only with the "words to ignore" list option. Otherwise, it would just be half-baked.
Vote by External U.
5146 | December 07, 2015 06:57:29 PM GMT
Update: Actually make that -1, on the basis this is already available in Apache Commons: http://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/WordUtils.html#capitalize(java.lang.String) I don't think there's any reason for CFML to cover the same ground. Original vote stated: +1. I don't - however - think the "ignoreList" argument is fully rounded out. For a given situation, the ignore list is going to be the same for all usages of the function, so it makes little sense to have to specify it every time. It would probably be better to have this as a config option: either instance-wide, or application wide via a dictionary file, or similar. Additionally thought would need to go into how this approach would work when dealing with languages other than English and alphabets other than Roman (which is likely something that would not occur to our American friends, but would be essential for most other situations). A better idea would perhaps be to not follow Aaron's idea (I only single out Aaron because he's the one who raised the issue), but to follow established style guides (eg: the Guardian Style Guide or similar) for these rules. I imagine this is actually well-trod ground in the Java world anyhow, so probably just following an established lead rather than inventing one is perhaps something to look at, too. It - however - should *not* be left up to computer programmers to come up with the rules here!
Vote by External U.
5147 | December 08, 2015 01:24:42 AM GMT
Hi Adam, Does WordUtils have an ignore list concept? I'm not seeing on here: https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/WordUtils.html I like the idea of ignoreList being more global, instead of as a parameter. And I like the idea of it being locale sensitive and to follow that style guide. Oh and I didn't realize we can change our votes till now - nice. Thanks!, -Aaron
Comment by External U.
5143 | December 20, 2015 06:13:58 AM GMT
I meant the overarching "titleCase" concept, not specifically the ignore list thing. I thought the rest of my comment kinda pointed out it was a fool's errand.
Comment by External U.
5144 | December 22, 2015 05:49:49 AM GMT
Hi Adam, I was referring to "Actually make that -1, on the basis this is already available in Apache Commons". By "this", I thought you were referring to this ER (including ability to ignore words). Thanks!, -Aaron
Comment by External U.
5145 | January 05, 2016 02:40:34 AM GMT