Skip to content

Sentence-case a string

Normalizes a string to sentence case: first character upper case, remainder lower case.

Field Value
Operation ID op-04-sentence-case
Trigger Caller normalizes a string for sentence-style display
Inputs String value
Outputs Sentence-cased string
Primary components mdlTextConversion.ToSentenceCase
Entry point SAIF.Business.Utilities/mdlTextConversion.vb

Steps

  1. Return Nothing when the target is Nothing.
  2. Return the value unchanged when length is 0.
  3. Upper-case it when length is 1.
  4. Otherwise upper-case the first character and lower-case the remainder (BR-017).

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Caller invokes ToSentenceCase]) --> CheckNothing{Target is Nothing?}
    CheckNothing -->|Yes| ReturnNothing([Return Nothing])
    CheckNothing -->|No| CheckLen0{Length = 0?}
    CheckLen0 -->|Yes| ReturnUnchanged([Return value unchanged])
    CheckLen0 -->|No| CheckLen1{Length = 1?}
    CheckLen1 -->|Yes| UpperOnly([Upper-case the character])
    CheckLen1 -->|No| UpperFirst["Upper-case first character,<br>lower-case remainder"]
    ReturnNothing --> Done([Return result])
    ReturnUnchanged --> Done
    UpperOnly --> Done
    UpperFirst --> Done

Failure and edge-case behavior

  • No exceptions are raised. Nothing input returns Nothing, zero-length input is returned unchanged, and single-character input is upper-cased without lower-casing any remainder.

Sources

  • SAIF.Business.Utilities/mdlTextConversion.vb