2009/2/23 Iñáki Baz Castillo <ibc / aliax.net>: > Hi, I've a module with two methods (thanks Jeff): > - hex_unescape(string) > - hex_scape(string) > as follows: > > def self::hex_unescape(str) > str.gsub(/%([0-9a-fA-F]{2})/) { $1.to_i(16).chr } > end > > def self::hex_escape(str) > str.gsub(/[^a-zA-Z0-9_\-.]/n) { sprintf("%%%02X", $&.unpack("C")[0]) } > end > > "hex_escape" method is copied from CGI lib, and sincerelly I don't like too > much its approach using "sprintf". Is there other way more ellegant? > (performance is the mos important requeriment anyway). Then I am sure you _measured_ it and came to the conclusion that it is too slow, did you? What are your results and what are your performance requirements? Cheers robert -- remember.guy do |as, often| as.you_can - without end