Project

General

Profile

Actions

Feature #11814

closed

String#valid_encoding? without force_encoding

Added by usa (Usaku NAKAMURA) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:72098]

Description

Now we have to set a encoding to a string to validate it, just like:

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?.

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) valid_encoding.patch usa (Usaku NAKAMURA), 12/13/2015 12:38 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0