TitleCase
Function TitleCase( const aString : String) : String
Example
procedure ScriptEvent(var Value: variant);
begin
Value := TitleCase('AN INTRODUCTION TO EDI'); // An Introduction to Edi
end;
Usage
TitleCase applies Velox's fixed English-oriented title-casing rules to space-delimited words.
Important behavior and quirks
- Input is split on ordinary spaces by
SplitString. Leading and trailing whitespace is removed, repeated spaces collapse and the result is rejoined with one space. - Override punctuation must be its own space-delimited token.
part: nextdoes not trigger the:rule;part : nextdoes. - Every token is first passed through locale-dependent
AnsiLowerCase. Except for fixed all-uppercase values, only the first ASCIIathroughzfound in the token is then uppercased. - The fixed list does not include business acronyms such as
EDI, personal-name rules, apostrophe rules or hyphenated-word rules. - Empty or whitespace-only input returns empty.
Use ProperCase when a mapping needs domain-specific acronyms or different exception words.
Additional Technical Info
TitleCase calls ProperCase with fixed Velox rule lists. It is intended for simple English-oriented labels and titles, not linguistically complete title casing.
The example is fictional and source-reviewed only. EDI becomes Edi because it is not in the function's fixed all-uppercase list.
Fixed rule lists
| Rule | Values |
|---|---|
| Keep lower case in an unforced middle position | a, an, and, but, by, for, in, into, is, of, off, on, onto, or, the, to |
| Capitalise the following token | -, :, ; |
| Force all upper case | a.m., p.m., b.c., a.d. |
The first and last token are always capitalised unless the token is in the all-uppercase list. A lower-case exception is also overridden when its preceding original token exactly matches one of the three standalone punctuation tokens.
Performance and concurrency
The implementation allocates token and rule arrays for each call, then performs linear comparisons against the small fixed lists. It uses no mutable shared state, although locale-sensitive casing can depend on the process environment.
Related entries
ProperCase- the configurable implementation used by this function.SplitString- the exact space tokeniser used byProperCase.