2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
9
9
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
10
//
11
11
//===----------------------------------------------------------------------===//
12
+ //
13
+ // [SE-0163] UnicodeCodec and UnicodeDecodingResult are "soft deprecated" only.
14
+ // See the API_TO_BE_DEPRECATED macro in the <os/availability.h> header.
15
+ // Another evolution proposal might be required, to formally deprecate them.
16
+ //
17
+ //===----------------------------------------------------------------------===//
12
18
13
19
import SwiftShims
14
20
@@ -20,6 +26,7 @@ import SwiftShims
20
26
/// Each `UnicodeDecodingResult` instance can represent a Unicode scalar value,
21
27
/// an indication that no more Unicode scalars are available, or an indication
22
28
/// of a decoding error.
29
+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
23
30
@frozen
24
31
public enum UnicodeDecodingResult : Equatable {
25
32
/// A decoded Unicode scalar value.
@@ -30,23 +37,6 @@ public enum UnicodeDecodingResult: Equatable {
30
37
31
38
/// An indication of a decoding error.
32
39
case error
33
-
34
- @inlinable
35
- public static func == (
36
- lhs: UnicodeDecodingResult ,
37
- rhs: UnicodeDecodingResult
38
- ) -> Bool {
39
- switch ( lhs, rhs) {
40
- case ( . scalarValue( let lhsScalar) , . scalarValue( let rhsScalar) ) :
41
- return lhsScalar == rhsScalar
42
- case ( . emptyInput, . emptyInput) :
43
- return true
44
- case ( . error, . error) :
45
- return true
46
- default :
47
- return false
48
- }
49
- }
50
40
}
51
41
52
42
/// A Unicode encoding form that translates between Unicode scalar values and
@@ -58,6 +48,7 @@ public enum UnicodeDecodingResult: Equatable {
58
48
/// UTF-8, UTF-16, and UTF-32 encoding schemes as the `UTF8`, `UTF16`, and
59
49
/// `UTF32` types, respectively. Use the `Unicode.Scalar` type to work with
60
50
/// decoded Unicode scalar values.
51
+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
61
52
public protocol UnicodeCodec : Unicode . Encoding {
62
53
63
54
/// Creates an instance of the codec.
@@ -139,6 +130,7 @@ public protocol UnicodeCodec: Unicode.Encoding {
139
130
140
131
/// A codec for translating between Unicode scalar values and UTF-8 code
141
132
/// units.
133
+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
142
134
extension Unicode . UTF8 : UnicodeCodec {
143
135
/// Creates an instance of the UTF-8 codec.
144
136
@inlinable
@@ -276,6 +268,9 @@ extension Unicode.UTF8: UnicodeCodec {
276
268
if _fastPath ( s == 0 ) { return }
277
269
processCodeUnit ( UInt8 ( truncatingIfNeeded: s) &- 0x01 )
278
270
}
271
+ }
272
+
273
+ extension Unicode . UTF8 {
279
274
280
275
/// Returns a Boolean value indicating whether the specified code unit is a
281
276
/// UTF-8 continuation byte.
@@ -316,6 +311,7 @@ extension Unicode.UTF8: UnicodeCodec {
316
311
317
312
/// A codec for translating between Unicode scalar values and UTF-16 code
318
313
/// units.
314
+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
319
315
extension Unicode . UTF16 : UnicodeCodec {
320
316
/// Creates an instance of the UTF-16 codec.
321
317
@inlinable
@@ -428,6 +424,7 @@ extension Unicode.UTF16: UnicodeCodec {
428
424
429
425
/// A codec for translating between Unicode scalar values and UTF-32 code
430
426
/// units.
427
+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
431
428
extension Unicode . UTF32 : UnicodeCodec {
432
429
/// Creates an instance of the UTF-32 codec.
433
430
@inlinable
@@ -643,6 +640,7 @@ extension Unicode.Scalar {
643
640
}
644
641
}
645
642
643
+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
646
644
extension UnicodeCodec {
647
645
@inlinable
648
646
public static func _nullCodeUnitOffset(
0 commit comments