Skip to main content

Text.to_case

to_casecase_optionlocale

Group: Text
Aliases: lower, proper, title, upper

Documentation

Converts each character in self to the specified case.

Arguments

  • case_option: specifies how to convert the characters.
  • locale: specifies the locale for character case mapping. Defaults to Locale.default.

Examples

Converting a text to lower case in the default locale:

      "My TeXt!".to_case == "my text!"

Converting a text to upper case in a specified locale:

      from Standard.Base import all

example_case_with_locale = "i".to_case Upper (Locale.new "tr") == "İ"

Remarks

What is a Character?

A character is defined as an Extended Grapheme Cluster, see Unicode Standard Annex 29. This is the smallest unit that still has semantic meaning in most text-processing applications.

What is title case?

Title case capitalizes the first letter of every word and ensures that all the remaining letters are in lower case. Some definitions of title case avoid capitalizing minor words (like the article "the" in English) but this implementation treats all words in the same way.