On Mar 3, 2009, at 4:18 PM, Rich Morin wrote:

It looks to me like this is a solution for a different problem;
that is, discarding characters outside of the specified range.
Also, do we want to map newlines, etc?  Anyway, irb sez:

Oops, I misread that. Yeah, gsub is probably faster.

string.unpack('U*').map { |c| (0x20..0x7e).include?(c) ? c : 32 }.pack('U*')

Anyway, just throwing out characters doesn't seem like a likely use- case anyway.

Manfred
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to