22//
33// This source file is part of the Swift.org open source project
44//
5- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+ // Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66// Licensed under Apache License v2.0 with Runtime Library Exception
77//
88// See https://swift.org/LICENSE.txt for license information
99// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010//
1111//===----------------------------------------------------------------------===//
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+ //===----------------------------------------------------------------------===//
1218
1319import SwiftShims
1420
@@ -20,6 +26,7 @@ import SwiftShims
2026/// Each `UnicodeDecodingResult` instance can represent a Unicode scalar value,
2127/// an indication that no more Unicode scalars are available, or an indication
2228/// of a decoding error.
29+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
2330@frozen
2431public enum UnicodeDecodingResult : Equatable {
2532 /// A decoded Unicode scalar value.
@@ -30,23 +37,6 @@ public enum UnicodeDecodingResult: Equatable {
3037
3138 /// An indication of a decoding error.
3239 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- }
5040}
5141
5242/// A Unicode encoding form that translates between Unicode scalar values and
@@ -58,6 +48,7 @@ public enum UnicodeDecodingResult: Equatable {
5848/// UTF-8, UTF-16, and UTF-32 encoding schemes as the `UTF8`, `UTF16`, and
5949/// `UTF32` types, respectively. Use the `Unicode.Scalar` type to work with
6050/// decoded Unicode scalar values.
51+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
6152public protocol UnicodeCodec : Unicode . Encoding {
6253
6354 /// Creates an instance of the codec.
@@ -139,6 +130,7 @@ public protocol UnicodeCodec: Unicode.Encoding {
139130
140131/// A codec for translating between Unicode scalar values and UTF-8 code
141132/// units.
133+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
142134extension Unicode . UTF8 : UnicodeCodec {
143135 /// Creates an instance of the UTF-8 codec.
144136 @inlinable
@@ -276,6 +268,9 @@ extension Unicode.UTF8: UnicodeCodec {
276268 if _fastPath ( s == 0 ) { return }
277269 processCodeUnit ( UInt8 ( truncatingIfNeeded: s) &- 0x01 )
278270 }
271+ }
272+
273+ extension Unicode . UTF8 {
279274
280275 /// Returns a Boolean value indicating whether the specified code unit is a
281276 /// UTF-8 continuation byte.
@@ -316,6 +311,7 @@ extension Unicode.UTF8: UnicodeCodec {
316311
317312/// A codec for translating between Unicode scalar values and UTF-16 code
318313/// units.
314+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
319315extension Unicode . UTF16 : UnicodeCodec {
320316 /// Creates an instance of the UTF-16 codec.
321317 @inlinable
@@ -428,6 +424,7 @@ extension Unicode.UTF16: UnicodeCodec {
428424
429425/// A codec for translating between Unicode scalar values and UTF-32 code
430426/// units.
427+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
431428extension Unicode . UTF32 : UnicodeCodec {
432429 /// Creates an instance of the UTF-32 codec.
433430 @inlinable
@@ -643,6 +640,7 @@ extension Unicode.Scalar {
643640 }
644641}
645642
643+ @available ( swift, deprecated: 100000 , message: " [SE-0163] Use the Unicode.Encoding APIs " )
646644extension UnicodeCodec {
647645 @inlinable
648646 public static func _nullCodeUnitOffset(
0 commit comments