@@ -40,20 +40,23 @@ public extension SwiftString {
4040 while te. MoveNext ( ) {
4141 stringData. append ( Character ( nativeStringValue: te. Current as! NativeString ) )
4242 }
43- #elseif COCOA
43+ #elseif DARWIN
4444 var i = 0
4545 while i < length ( string) {
4646
47- let sequenceLength = string. rangeOfComposedCharacterSequenceAtIndex ( i) . length
47+ let sequenceLength = ( string as! NSString ) . rangeOfComposedCharacterSequenceAtIndex ( i) . length
4848
4949 //76192: Silver: can't use range as subscript? (SBL)
5050 let ch : NativeString = string. __substring ( range: i ..< i+ sequenceLength)
5151 stringData. append ( Character ( nativeStringValue: ch) )
5252 i += sequenceLength
5353 }
54+ #elseif ISLAND
55+ #hint Not implemented yet
5456 #endif
5557
56- /* old logic to detect surrogate pairs; not needed right now
58+ /* old logic to detect surrogate pairs; not needed right now
59+ {
5760 let c = string[i]
5861 let c2 = Int(c)
5962 /*switch Int(c) {
@@ -99,8 +102,8 @@ public extension SwiftString {
99102 addCharacter()
100103
101104 i += 1
102- }*/
103- //addCharacter()
105+ }
106+ //addCharacter()*/
104107 }
105108
106109 public override var count : Int { return stringData. count }
@@ -178,6 +181,13 @@ public extension SwiftString {
178181 return stringData [ index]
179182 }
180183
184+ @Sequence
185+ public func GetSequence( ) -> ISequence < Char > {
186+ for i in startIndex ..< endIndex {
187+ __yield self[ i]
188+ }
189+ }
190+
181191 @ToString public func description( ) -> NativeString {
182192 var result = " UTF16CharacterView( "
183193 for i in startIndex..< endIndex {
@@ -191,10 +201,9 @@ public extension SwiftString {
191201 }
192202 }
193203
194- #if !ISLAND
195204 public typealias UnicodeScalarView = UTF32View
196205
197- public class UTF32View : BaseCharacterView /*, ISequence<UTF32Char>*/ {
206+ public class UTF32View : BaseCharacterView {
198207 private let stringData : Byte [ ]
199208
200209 private init ( stringData: Byte [ ] ) {
@@ -207,7 +216,7 @@ public extension SwiftString {
207216 #elseif CLR
208217 stringData = System . Text. UTF32Encoding ( /*bigendian:*/false , /*BOM:*/false ) . GetBytes ( string) // todo check order
209218 #elseif ISLAND
210- stringData = Encoding . UTF32LE. GetBytes ( aValue , /*BOM:*/false ) // todo check order
219+ stringData = System . Encoding. UTF32LE. GetBytes ( string , /*BOM:*/false ) // todo check order
211220 #elseif COCOA
212221 if let utf32 = string. dataUsingEncoding ( . NSUTF32LittleEndianStringEncoding) { // todo check order
213222 stringData = Byte [ ] ( capacity: utf32. length) ;
@@ -263,9 +272,7 @@ public extension SwiftString {
263272 return result
264273 }
265274 }
266- #endif
267275
268- #if !ISLAND
269276 public class UTF8View : BaseCharacterView {
270277 internal let stringData : UTF8Char [ ]
271278
@@ -279,7 +286,7 @@ public extension SwiftString {
279286 #elseif CLR
280287 stringData = System . Text. UTF8Encoding ( /*BOM:*/false ) . GetBytes ( string)
281288 #elseif ISLAND
282- stringData = Encoding . UTF8. GetBytes ( aValue , /*BOM:*/false )
289+ stringData = System . Encoding. UTF8. GetBytes ( string , /*BOM:*/false ) as! UTF8Char [ ]
283290 #elseif COCOA
284291 if let utf8 = string. dataUsingEncoding ( . NSUTF8StringEncoding) {
285292 stringData = UTF8Char [ ] ( capacity: utf8. length) ;
@@ -316,6 +323,11 @@ public extension SwiftString {
316323 return stringData [ index]
317324 }
318325
326+ @Sequence
327+ public func GetSequence( ) -> ISequence < UTF8Char > {
328+ return stringData
329+ }
330+
319331 @ToString public func description( ) -> NativeString {
320332 var result = " UTF8CharacterView( "
321333 for i in startIndex..< endIndex {
@@ -328,6 +340,4 @@ public extension SwiftString {
328340 return result
329341 }
330342 }
331- #endif
332-
333343}
0 commit comments