From: naruse@... Date: 2015-12-14T07:14:29+00:00 Subject: [ruby-core:72104] [Ruby trunk - Feature #11814] [Rejected] String#valid_encoding? without force_encoding Issue #11814 has been updated by Yui NARUSE. Status changed from Open to Rejected knu says it is to guess the encoding. ruby shouldn't help such hard and often misused work. ---------------------------------------- Feature #11814: String#valid_encoding? without force_encoding https://bugs.ruby-lang.org/issues/11814#change-55520 * Author: Usaku NAKAMURA * Status: Rejected * Priority: Normal * Assignee: ---------------------------------------- Now we have to set a encoding to a string to validate it, just like: ```ruby str.force_encoding('euc-jp').valid_encoding? # => true or false ``` But to modify the string is not so smart. knu-san requires the way to validate a string without modifiing it [*1]. Then, I propose to add an optional encoding parameter to `String#valid_encoding?`. ```ruby str.valid_encoding?('euc-jp') # => true or false ``` A patch is attached. [*1] https://twitter.com/knu/status/676009662655934465 (in Japanese) ---Files-------------------------------- valid_encoding.patch (4.4 KB) -- https://bugs.ruby-lang.org/