Project

General

Profile

Feature #640

New Array#encoding_pack -> string method

Added by mike (Michael Selig) almost 12 years ago. Updated over 9 years ago.

Status:
Rejected
Priority:
Normal
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

#1

Updated by ko1 (Koichi Sasada) almost 12 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

=begin

=end

#2

Updated by naruse (Yui NARUSE) almost 11 years ago

  • Status changed from Open to Rejected

=begin

=end

Also available in: Atom PDF