Well, my medication has finally worn off, and I came up with this:
a_string.tr('^ -~', ' ') Any comments on efficiency?
God bless ascii for being contiguous. All this is to clean up
imperfectly mapped EBCDIC (eeeww!)
Thanks for the suggestions.
Bob Schaaf
On Mar 3, 2009, at 10:34 AM, Manfred Stienstra wrote:
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
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel