* [ruby-core:122582] [Ruby Bug#21450] Inconsistent `upcase` between `String` and `Symbol`
@ 2025-06-23 15:15 Stranger6667 (Dmitry Dygalo) via ruby-core
2025-06-24 6:56 ` [ruby-core:122590] " nobu (Nobuyoshi Nakada) via ruby-core
0 siblings, 1 reply; 2+ messages in thread
From: Stranger6667 (Dmitry Dygalo) via ruby-core @ 2025-06-23 15:15 UTC (permalink / raw)
To: ruby-core; +Cc: Stranger6667 (Dmitry Dygalo)
Issue #21450 has been reported by Stranger6667 (Dmitry Dygalo).
----------------------------------------
Bug #21450: Inconsistent `upcase` between `String` and `Symbol`
https://bugs.ruby-lang.org/issues/21450
* Author: Stranger6667 (Dmitry Dygalo)
* Status: Open
* 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` 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 mapping on `Symbol` works the same way as with `String`:
```ruby
: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/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-core:122590] [Ruby Bug#21450] Inconsistent `upcase` between `String` and `Symbol`
2025-06-23 15:15 [ruby-core:122582] [Ruby Bug#21450] Inconsistent `upcase` between `String` and `Symbol` Stranger6667 (Dmitry Dygalo) via ruby-core
@ 2025-06-24 6:56 ` nobu (Nobuyoshi Nakada) via ruby-core
0 siblings, 0 replies; 2+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-06-24 6:56 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
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 #=> #<Encoding:UTF-8>
:i.encoding #=> #<Encoding:US-ASCII>
```
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-24 6:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-23 15:15 [ruby-core:122582] [Ruby Bug#21450] Inconsistent `upcase` between `String` and `Symbol` Stranger6667 (Dmitry Dygalo) via ruby-core
2025-06-24 6:56 ` [ruby-core:122590] " nobu (Nobuyoshi Nakada) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).