[ruby-core:109546] [Ruby master Bug#18958] Kernel#sprintf doesn't apply format sequence in some encodings
From:
"mame (Yusuke Endoh)" <noreply@...>
Date:
2022-08-18 09:45:52 UTC
List:
ruby-core #109546
Issue #18958 has been updated by mame (Yusuke Endoh).
@naruse, @nobu, and @matz agreed that it should raise an exception if the format string is not ASCII-compatible.
----------------------------------------
Bug #18958: Kernel#sprintf doesn't apply format sequence in some encodings
https://bugs.ruby-lang.org/issues/18958#change-98717
* 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>