Project

General

Profile

Actions

Feature #10237

open

Transform all elements of one Encoding into another Encoding for Array and Hash

Added by shevegen (Robert A. Heiler) over 9 years ago. Updated about 6 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:65020]

Description

I find myself to sometimes have to convert one encoding to the other.

For string objects, this is trivial:

.encode()
.force_encoding()

For reading in a file via File.readlines(), this is also
simple because of stuff like:

File.readlines('test.txt', :encoding => 'ascii-8bit')

For Array and Hashes, however, this is a bit annoying for me.

I'd love to have an .encode method as well.

This method should try to convert all elements on an Array
or a Hash to another encoding IF they are a string object.

I'd like to be able to treat Array and Hashes in the same
way, so that I can e. g. convert a hash dictionary from
one encoding to the other quickly.

It already is possible of course, with some extra lines
of code, but I'd love to have a way to do so with just
one method call.

:

Actions #1

Updated by naruse (Yui NARUSE) about 6 years ago

  • Target version deleted (2.2.0)
Actions

Also available in: Atom PDF

Like0
Like0