From: Michael Selig Date: 2008-10-12T08:23:21+09:00 Subject: [ruby-core:19299] [Feature #640] New Array#encoding_pack -> string method Feature #640: New Array#encoding_pack -> string method http://redmine.ruby-lang.org/issues/show/640 Author: Michael Selig Status: Open, Priority: Normal Category: M17N 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 ---------------------------------------- http://redmine.ruby-lang.org