I
Iñaki Baz Castillo
Hi, I've a module with two methods (thanks Jeff):
=2D hex_unescape(string)
=2D 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=
=20
much its approach using "sprintf". Is there other way more ellegant?=20
(performance is the mos important requeriment anyway).
Thanks a lot.
=2D-=20
I=C3=B1aki Baz Castillo
=2D hex_unescape(string)
=2D 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=
=20
much its approach using "sprintf". Is there other way more ellegant?=20
(performance is the mos important requeriment anyway).
Thanks a lot.
=2D-=20
I=C3=B1aki Baz Castillo