Actions
Feature #640
closedNew Array#encoding_pack -> string method
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
Like0
Like0Like0