3 Some string-oriented methods use case mapping.
27 == Default Case Mapping
29 By default, all of these methods use full Unicode case mapping,
30 which is suitable for most languages.
31 See {Section 3.13 (Default Case Algorithms) of the Unicode standard}[https://www.unicode.org/versions/latest/ch03.pdf].
33 Non-ASCII case mapping and folding are supported for UTF-8,
34 UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1~16 Strings/Symbols.
36 Context-dependent case mapping as described in
37 {Table 3-17 (Context Specification for Casing) of the Unicode standard}[https://www.unicode.org/versions/latest/ch03.pdf]
38 is currently not supported.
40 In most cases, case conversions of a string have the same number of characters.
41 There are exceptions (see also +:fold+ below):
48 Case mapping may also depend on locale (see also +:turkic+ below):
51 s.downcase # => "i" # Dot above.
52 s.downcase(:turkic) # => "ı" # No dot above.
54 Case changes may not be reversible:
56 s = 'Hello World!' # => "Hello World!"
57 s.downcase # => "hello world!"
58 s.downcase.upcase # => "HELLO WORLD!" # Different from original s.
60 Case changing methods may not maintain Unicode normalization.
61 See String#unicode_normalize).
63 == Options for Case Mapping
65 Except for +casecmp+ and +casecmp?+,
66 each of the case-mapping methods listed above
67 accepts optional arguments, <tt>*options</tt>.
73 - +:turkic+ or +:lithuanian+ or both.
79 uppercase letters ('A'..'Z') are mapped to lowercase letters ('a'..'z);
80 other characters are not changed
82 s = "Foo \u00D8 \u00F8 Bar" # => "Foo Ø ø Bar"
83 s.upcase # => "FOO Ø Ø BAR"
84 s.downcase # => "foo ø ø bar"
85 s.upcase(:ascii) # => "FOO Ø ø BAR"
86 s.downcase(:ascii) # => "foo Ø ø bar"
89 Full Unicode case mapping, adapted for the Turkic languages
90 that distinguish dotted and dotless I, for example Turkish and Azeri.
92 s = 'Türkiye' # => "Türkiye"
93 s.upcase # => "TÜRKIYE"
94 s.upcase(:turkic) # => "TÜRKİYE" # Dot above.
96 s = 'TÜRKIYE' # => "TÜRKIYE"
97 s.downcase # => "türkiye"
98 s.downcase(:turkic) # => "türkıye" # No dot above.
103 - +:fold+ (available only for String#downcase, String#downcase!,
104 and Symbol#downcase):
105 Unicode case folding,
106 which is more far-reaching than Unicode case mapping.
108 s = "\u00DF" # => "ß"
110 s.downcase(:fold) # => "ss"
113 s = "\uFB04" # => "ffl"
116 s.downcase(:fold) # => "ffl"