You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SwiftASCII/String.swift
+33-1Lines changed: 33 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,14 @@ import Foundation
10
10
11
11
extensionString{
12
12
13
+
/// Converts a String to `ASCIIString` exactly.
14
+
/// Returns nil if `self` is not encodable as ASCII.
15
+
@inlinablepublicvarasciiString:ASCIIString?{
16
+
ASCIIString(exactly:self)
17
+
}
18
+
19
+
/// Converts a String to `ASCIIString` lossily.
20
+
///
13
21
/// Performs a lossy conversion, transforming characters to printable ASCII substitutions where necessary.
14
22
///
15
23
/// Note that some characters may be transformed to representations that occupy more than one ASCII character. For example: char 189 (½) will be converted to "1/2"
/// Returns nil if `self` is not encodable as ASCII.
51
+
@inlinablepublicvarasciiString:ASCIIString?{
52
+
ASCIIString(exactly:String(self))
53
+
}
54
+
55
+
/// Converts a String to `ASCIIString` lossily.
56
+
///
57
+
/// Performs a lossy conversion, transforming characters to printable ASCII substitutions where necessary.
58
+
///
59
+
/// Note that some characters may be transformed to representations that occupy more than one ASCII character. For example: char 189 (½) will be converted to "1/2"
60
+
///
61
+
/// Where a suitable character substitution can't reasonably be performed, a question-mark "?" will be substituted.
0 commit comments