We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c82d167 commit 07f38c4Copy full SHA for 07f38c4
Sources/FoundationEssentials/String/String+IO.swift
@@ -112,7 +112,17 @@ extension String {
112
self = string
113
} else {
114
// String is not valid UTF8
115
+#if FOUNDATION_FRAMEWORK && os(macOS)
116
+ // Allow for invalid UTF8 to be repaired in compatibility cases
117
+ if Self.compatibiltity2 {
118
+ self = String(decoding: Array(bytes), as: UTF8.self)
119
+ } else {
120
+ return nil
121
+ }
122
+
123
+#else
124
return nil
125
+#endif
126
}
127
case .utf16BigEndian, .utf16LittleEndian, .utf16:
128
// See also the package extension String?(_utf16:), which does something similar to this without the swapping of big/little.
0 commit comments