Index: /branches/ide-1.0/ccl/examples/objc-support.lisp
===================================================================
--- /branches/ide-1.0/ccl/examples/objc-support.lisp	(revision 6584)
+++ /branches/ide-1.0/ccl/examples/objc-support.lisp	(revision 6585)
@@ -153,13 +153,7 @@
 
 
-(defun %make-nsstring-from-c-string (s)
-  (#/initWithCString: (#/alloc ns:ns-string) s))
-
-(defun %make-nsstring-from-utf32-string (s nbytes)
-  (#/initWithBytes:length:encoding: (#/alloc ns:ns-string)
-                                    s
-                                    nbytes
-                                    #+big-endian-target #x98000100
-                                    #+little-endian-target #x9c000100))
+(defun %make-nsstring-from-utf8-c-string (s)
+  (#/initWithUTF8String: (#/alloc ns:ns-string) s))
+
 
 (defun retain-objc-instance (instance)
@@ -173,5 +167,23 @@
   (#/release p))
 
-;;; This can fail if the nsstring contains non-8-bit characters.
+
+#-ascii-only
+(defun lisp-string-from-nsstring (nsstring)
+  ;; The NSData object created here is autoreleased.
+  (let* ((data (#/dataUsingEncoding:allowLossyConversion:
+                nsstring
+                #+little-endian-target #x9c000100
+                #+big-endian-target #x98000100
+                nil)))
+    (unless (%null-ptr-p data)
+      (let* ((nbytes (#/length data))
+             (string (make-string (ash nbytes -2))))
+        ;; BLT the 4-byte code-points from the NSData object
+        ;; to the string, return the string.
+        (%copy-ptr-to-ivector (#/bytes data) 0 string 0 nbytes)))))
+        
+
+
+#+ascii-only
 (defun lisp-string-from-nsstring (nsstring)
   (with-macptrs (cstring)
@@ -206,5 +218,5 @@
   ;;; this condition.
 
-  ;; (dbg (format nil "~a" c))
+   (dbg (format nil "~a" c))
   ;;(#_NSLog #@"Lisp exception: %@" :id (%make-nsstring (format nil "~a" c)))
   (make-instance 'ns-lisp-exception :condition c))
