ruby/doc/string/upcase.rdoc
2025-12-05 19:04:59 -08:00

28 lines
868 B
Plaintext

Returns a new string containing the upcased characters in +self+:
'hello'.upcase # => "HELLO"
'straße'.upcase # => "STRASSE"
'привет'.upcase # => "ПРИВЕТ"
'RubyGems.org'.upcase # => "RUBYGEMS.ORG"
The sizes of +self+ and the upcased result may differ:
s = 'Straße'
s.size # => 6
s.upcase # => "STRASSE"
s.upcase.size # => 7
Some characters (and some character sets) do not have upcase and downcase versions;
see {Case Mapping}[rdoc-ref:case_mapping.rdoc]:
s = '1, 2, 3, ...'
s.upcase == s # => true
s = 'こんにちは'
s.upcase == s # => true
The casing is affected by the given +mapping+,
which may be +:ascii+, +:fold+, or +:turkic+;
see {Case Mappings}[rdoc-ref:case_mapping.rdoc@Case+Mappings].
Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].