File tree Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -88,25 +88,26 @@ extension Character {
88
88
}
89
89
90
90
extension Character {
91
- @usableFromInline
92
- typealias UTF8View = String . UTF8View
91
+ /// A view of a character's contents as a collection of UTF-8 code units. See
92
+ /// String.UTF8View for more information
93
+ public typealias UTF8View = String . UTF8View
93
94
95
+ /// A UTF-8 encoding of `self`.
94
96
@inlinable
95
- internal var utf8 : UTF8View {
96
- return _str . utf8
97
- }
98
- @ usableFromInline
99
- typealias UTF16View = String . UTF16View
97
+ public var utf8 : UTF8View { return _str . utf8 }
98
+
99
+ /// A view of a character's contents as a collection of UTF-16 code units. See
100
+ /// String.UTF16View for more information
101
+ public typealias UTF16View = String . UTF16View
100
102
103
+ /// A UTF-16 encoding of `self`.
101
104
@inlinable
102
- internal var utf16 : UTF16View {
103
- return _str. utf16
104
- }
105
+ public var utf16 : UTF16View { return _str. utf16 }
106
+
105
107
public typealias UnicodeScalarView = String . UnicodeScalarView
108
+
106
109
@inlinable
107
- public var unicodeScalars : UnicodeScalarView {
108
- return _str. unicodeScalars
109
- }
110
+ public var unicodeScalars : UnicodeScalarView { return _str. unicodeScalars }
110
111
}
111
112
112
113
extension Character :
Original file line number Diff line number Diff line change @@ -347,6 +347,19 @@ CharacterTests.test("String.append(_: Character)") {
347
347
}
348
348
}
349
349
350
+ CharacterTests . test ( " utf6/16/unicodescalar views " ) {
351
+ for c in testCharacters {
352
+ expectEqualSequence ( String ( c) . unicodeScalars, c. unicodeScalars)
353
+ expectEqualSequence ( String ( c) . utf8, c. utf8)
354
+ expectEqualSequence ( String ( c) . utf16, c. utf16)
355
+
356
+ expectEqualSequence (
357
+ String ( c) . unicodeScalars. reversed ( ) , c. unicodeScalars. reversed ( ) )
358
+ expectEqualSequence ( String ( c) . utf8. reversed ( ) , c. utf8. reversed ( ) )
359
+ expectEqualSequence ( String ( c) . utf16. reversed ( ) , c. utf16. reversed ( ) )
360
+ }
361
+ }
362
+
350
363
var UnicodeScalarTests = TestSuite ( " UnicodeScalar " )
351
364
352
365
UnicodeScalarTests . test ( " UInt8(ascii: UnicodeScalar) " ) {
You can’t perform that action at this time.
0 commit comments