From: "nobu (Nobuyoshi Nakada) via ruby-core" Date: 2025-06-24T06:56:16+00:00 Subject: [ruby-core:122590] [Ruby Bug#21450] Inconsistent `upcase` between `String` and `Symbol` Issue #21450 has been updated by nobu (Nobuyoshi Nakada). Status changed from Open to Closed That difference is because of the difference of encodings. The string `"i"` is UTF-8, even it contains ASCII 7bit characters only, because the source encoding is defaulted to UTF-8. On the other hand, the encoding of a symbol, `:i`, that contains ASCII 7bit characters only is US-ASCII. ```ruby "i".encoding #=> # :i.encoding #=> # ``` The string in US-ASCII does the same behavior as the symbol. ```ruby "i".encode("us-ascii").upcase(:turkic) #=> "I" ``` ---------------------------------------- Bug #21450: Inconsistent `upcase` between `String` and `Symbol` https://bugs.ruby-lang.org/issues/21450#change-113825 * Author: Stranger6667 (Dmitry Dygalo) * Status: Closed * ruby -v: 3.4 * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- Behavior for `Symbol#upcase` and `String#upcase` differs for `i` character if the `:turkic` option is present I'd expect `val.upcase(:turkic)` behaves consistently for both cases: ```ruby 'i'.upcase(:turkic) # "��" with dot :i.upcase(:turkic) # :I no dot ``` However, when a non-ASCII character is present, then the case mapping on `Symbol` works the same way as with `String`: ```ruby :i��.upcase(:turkic) # :���� # with dot 'i��'.upcase(:turkic) # "����" # with dot ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/