Files

Class Index [+]

Quicksearch

Case Mapping

Some string-oriented methods use case mapping.

In String:

In Symbol:

Default Case Mapping

By default, all of these methods use full Unicode case mapping, which is suitable for most languages. See Unicode Latin Case Chart.

Non-ASCII case mapping and folding are supported for UTF-8, UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1~16 Strings/Symbols.

Context-dependent case mapping as described in Table 3-17 of the Unicode standard is currently not supported.

In most cases, case conversions of a string have the same number of characters. There are exceptions (see also :fold below):

s = "\u00DF" # => "ß"
s.upcase     # => "SS"
s = "\u0149" # => "ʼn"
s.upcase     # => "ʼN"

Case mapping may also depend on locale (see also :turkic below):

s = "\u0049"        # => "I"
s.downcase          # => "i" # Dot above.
s.downcase(:turkic) # => "ı" # No dot above.

Case changes may not be reversible:

s = 'Hello World!' # => "Hello World!"
s.downcase         # => "hello world!"
s.downcase.upcase  # => "HELLO WORLD!" # Different from original s.

Case changing methods may not maintain Unicode normalization. See String#unicode_normalize).

Options for Case Mapping

Except for casecmp and casecmp?, each of the case-mapping methods listed above accepts optional arguments, *options.

The arguments may be:

The options:

There is an updated format of the API docs for this version here.