String.st
changeset 8457 a00113e2f7bd
parent 8438 317f70e84d61
child 8458 b10d8cb3ab00
--- a/String.st	Tue Aug 03 19:02:29 2004 +0200
+++ b/String.st	Tue Aug 03 21:28:28 2004 +0200
@@ -484,7 +484,6 @@
     "Modified: 23.4.1996 / 16:00:38 / cg"
 ! !
 
-
 !String methodsFor:'accessing'!
 
 at:index
@@ -669,6 +668,35 @@
 
 !String methodsFor:'character searching'!
 
+contains8BitCharacters
+    "return true, if the underlying string contains 8BitCharacters (or widers) 
+     (i.e. if it is non-ascii)"
+
+%{  /* NOCONTEXT */
+
+    REGISTER unsigned char *cp;
+    REGISTER unsigned char *last;
+    OBJ cls;
+
+    cp = __stringVal(self);
+    if ((cls = __qClass(self)) != String) {
+        cp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+    }
+    for (last=cp+__stringSize(self); cp < last; cp++) {
+        if (*cp & 0x80) {
+            RETURN ( true );
+        }
+    }
+    RETURN (false);
+%}.
+
+    "
+     'hello world' contains8BitCharacters                                       
+     'hello world' asTwoByteString contains8BitCharacters                       
+     ('hello world' , (Character value:16r88) asString) contains8BitCharacters  
+    "
+!
+
 identityIndexOf:aCharacter
     "return the index of the first occurrences of the argument, aCharacter
      in the receiver or 0 if not found - reimplemented here for speed."
@@ -3001,8 +3029,6 @@
     ^ String
 ! !
 
-
-
 !String methodsFor:'testing'!
 
 endsWith:aStringOrChar
@@ -3346,5 +3372,5 @@
 !String class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.208 2004-07-13 07:31:03 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.209 2004-08-03 19:28:17 penk Exp $'
 ! !