Project

General

Profile

Actions

Feature #640

closed

New Array#encoding_pack -> string method

Added by mike (Michael Selig) over 15 years ago. Updated almost 13 years ago.

Status:
Rejected
Target version:
-
[ruby-core:19299]

Description

=begin
Now that we have String#each_codepoint there are times when you want to pack an array of integer codepoints back to a string. With UTF-8 you can use:
arr.pack("U*").force_encoding("UTF-8")
But I think it would be better to have a general method such as Array#encoding_pack(enc) -> string which efficiently handles any encoding, and is approximately a converse to String#each_codepoint.

A Ruby implementation might be:

class Array
def encoding_pack(enc)
s = "".force_encoding(enc)
each { |cp|
s << cp
}
s
end
end
=end

Actions #1

Updated by ko1 (Koichi Sasada) over 15 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

=begin

=end

Actions #2

Updated by naruse (Yui NARUSE) over 14 years ago

  • Status changed from Open to Rejected

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0