Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSString.d @ 139:86fc761a24ae
Fixes #11
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 04 Jun 2009 23:23:10 +0200 |
parents | 3d9eb62cd2e3 |
children | e91dcbf77cc7 |
comparison
equal
deleted
inserted
replaced
138:3d9eb62cd2e3 | 139:86fc761a24ae |
---|---|
19 import dwt.internal.cocoa.NSRange; | 19 import dwt.internal.cocoa.NSRange; |
20 import dwt.internal.cocoa.OS; | 20 import dwt.internal.cocoa.OS; |
21 import dwt.internal.objc.cocoa.Cocoa; | 21 import dwt.internal.objc.cocoa.Cocoa; |
22 import objc = dwt.internal.objc.runtime; | 22 import objc = dwt.internal.objc.runtime; |
23 | 23 |
24 import tango.stdc.stdlib; | |
25 | |
26 public class NSString : NSObject { | 24 public class NSString : NSObject { |
27 | 25 |
28 public this() { | 26 public this() { |
29 super(); | 27 super(); |
30 } | 28 } |
41 wchar[] buffer = new wchar[lengthOfCharacters]; | 39 wchar[] buffer = new wchar[lengthOfCharacters]; |
42 getCharacters(buffer.ptr); | 40 getCharacters(buffer.ptr); |
43 return dwt.dwthelper.utils.toString(buffer); | 41 return dwt.dwthelper.utils.toString(buffer); |
44 } | 42 } |
45 | 43 |
44 public wchar[] getString16() { | |
45 wchar[] buffer = new wchar[lengthOfCharacters]; | |
46 getCharacters(buffer.ptr); | |
47 return buffer; | |
48 } | |
49 | |
46 public static NSString stringWith(String str) { | 50 public static NSString stringWith(String str) { |
47 return stringWithUTF8String((str ~ '\0').ptr); | 51 return stringWithUTF8String((str ~ '\0').ptr); |
52 } | |
53 | |
54 public static NSString stringWith16(wchar[] buffer) { | |
55 return stringWithCharacters(buffer.ptr, buffer.length); | |
48 } | 56 } |
49 | 57 |
50 public /*const*/char* UTF8String() { | 58 public /*const*/char* UTF8String() { |
51 return cast(/*const*/char*) OS.objc_msgSend(this.id, OS.sel_UTF8String); | 59 return cast(/*const*/char*) OS.objc_msgSend(this.id, OS.sel_UTF8String); |
52 } | 60 } |