Convert text to title case¶
Converts a source string to title case via TitleCase.ToTitleCase / String.ToTitleCase, preserving all original delimiter characters and applying acronym/minor-word/suffix overrides.
| Field | Value |
|---|---|
| Operation ID | op-01-convert-to-title-case |
| Trigger | A caller formats a stored text value for display (e.g. clsPolicyAssociation.PolicyName) |
| Inputs | inString As String |
| Outputs | Title-cased string preserving all original delimiter characters |
| Primary components | TitleCase.ToTitleCase, String.ToTitleCase, ReassembleString, ApplyExactSuffixList |
| Entry point | SAIF.Business.Utilities/TitleCase.vb |
Steps¶
- Guard: if
inStringisNothingor trims to zero length, return the input unchanged (BR-001). No exception is raised. - Split
inString.TrimonRegex.Split(..., "[^\d\w]")— every non-letter/non-digit character becomes a split point, producing word tokens and empty strings where consecutive delimiters occurred. - If no token is non-blank, keep the original string (BR-002) and skip steps 4–5.
- Otherwise map each token through Case a single word, then call
ReassembleStringto rebuild the string, re-inserting the delimiter characters from the source at their original positions (BR-003). Leading delimiters are clipped off first, emitted verbatim, and the remainder is reassembled recursively. - Split the reassembled result on spaces and apply
ApplyExactSuffixListto each word — normalizes an's-style suffix to the canonical casing inMixedCaseSuffixList(BR-010). - Force the first character to upper case and return (BR-011).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Caller invokes ToTitleCase]) --> Guard{Null/blank?}
Guard -->|Yes| ReturnUnchanged([Return input unchanged])
Guard -->|No| Split["Split into tokens on<br>non-alnum delimiters"]
Split --> AnyToken{Any non-blank token?}
AnyToken -->|No| KeepOriginal([Keep original string])
AnyToken -->|Yes| MapTokens["Map each token via<br>TitleCaseSingleWord"]
MapTokens --> Reassemble["Reassemble with original<br>delimiters"]
Reassemble --> Suffix["Apply ApplyExactSuffixList<br>to each word"]
Suffix --> ForceFirst["Force first character upper<br>case"]
ForceFirst --> Done([Return title-cased string])
Failure and edge-case behavior¶
- No
Try/Catch. A source string whose delimiter positions do not align with the reassembly index can surface an index-out-of-range frominSourceString.ElementAt(...).**
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Related documentation¶
Sources¶
SAIF.Business.Utilities/TitleCase.vb