Bug #17011
Updated by nobu (Nobuyoshi Nakada) about 4 years ago
`BigDecimal#to_s` `BigDecimal` `.to_s` returns a `String` in ASCII-8BIT encoding. This is inconvenient in situations where the encoding determines program behaviour, since ASCII-8BIT is a special encoding that implies binary (non-textual) data, it can require an explicit conversion. `BigDecimal#to_s` `BigDecimal` `.to_s` should either use the currently active encoding, or it should use US-ASCII like `Integer#to_s`. `Integer` `.to_s`. Recreation script: ``` ruby # encoding: utf-8 Encoding.default_internal = Encoding::UTF_8 Encoding.default_external = Encoding::UTF_8 require 'bigdecimal' puts BigDecimal('2').to_s.encoding ``` Desired output: `US-ASCII` or `UTF-8` Actual output: `ASCII-8BIT`