[macruby-changes] [2043] MacRuby/branches/experimental/string.c

source_changes at macosforge.org source_changes at macosforge.org
Tue Jul 21 15:28:52 PDT 2009


Revision: 2043
          http://trac.macosforge.org/projects/ruby/changeset/2043
Author:   pthomson at apple.com
Date:     2009-07-21 15:28:52 -0700 (Tue, 21 Jul 2009)
Log Message:
-----------
Implemented String#ascii_only? using CFCharacterSets.

Modified Paths:
--------------
    MacRuby/branches/experimental/string.c

Modified: MacRuby/branches/experimental/string.c
===================================================================
--- MacRuby/branches/experimental/string.c	2009-07-21 22:28:51 UTC (rev 2042)
+++ MacRuby/branches/experimental/string.c	2009-07-21 22:28:52 UTC (rev 2043)
@@ -4938,7 +4938,11 @@
 static VALUE
 rb_str_is_ascii_only_p(VALUE str, SEL sel)
 {
-    rb_notimplement();
+	CFCharacterSetRef ascii = CFCharacterSetCreateWithCharactersInRange(NULL, CFRangeMake(0, 128));
+	CFCharacterSetRef this = CFCharacterSetCreateWithCharactersInString(NULL, (CFStringRef)str);
+	Boolean b = CFCharacterSetIsSupersetOfSet(ascii, this);
+	CFRelease(ascii); CFRelease(this);
+	return (b ? Qtrue : Qfalse);
 }
 
 static VALUE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090721/2193b051/attachment.html>


More information about the macruby-changes mailing list