[ruby-core:109535] [Ruby master Bug#18958] Kernel#sprintf doesn't apply format sequence in some encodings
From:
"matz (Yukihiro Matsumoto)" <noreply@...>
Date:
2022-08-18 09:06:50 UTC
List:
ruby-core #109535
Issue #18958 has been updated by matz (Yukihiro Matsumoto).
I agree with raising exception when the format string is not ASCII compatible.
Matz.
----------------------------------------
Bug #18958: Kernel#sprintf doesn't apply format sequence in some encodings
https://bugs.ruby-lang.org/issues/18958#change-98706
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
* ruby -v: 3.0.3
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I've noticed that `sprintf` does nothing (at least for `%f`) when format string is in the following encodings:
- UTF-16
- UTF-16BE
- UTF-16LE
- UTF-32
- UTF-32BE
- UTF-32LE
- UCS-2BE
- UCS-4BE
- UCS-4LE
- IBM037
- ebcdic-cp-us
Example:
```ruby
format = "%10.4f".encode("UTF-32")
sprintf(format, 12.34)
# => "\uFEFF%10.4f"
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>