mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[stdlib] String initialization with encoding and CString interop
This commit is contained in:
@@ -62,13 +62,15 @@ extension _UnicodeEncoding {
|
||||
}
|
||||
|
||||
/// Converts from encoding-independent to encoded representation, returning
|
||||
/// `nil` if the scalar can't be represented in this encoding.
|
||||
/// `encodedReplacementCharacter` if the scalar can't be represented in this
|
||||
/// encoding.
|
||||
public static func encode(_ content: UnicodeScalar) -> EncodedScalar {
|
||||
return encodeIfRepresentable(content) ?? encodedReplacementCharacter
|
||||
}
|
||||
|
||||
/// Converts a scalar from another encoding's representation, returning
|
||||
/// `nil` if the scalar can't be represented in this encoding.
|
||||
/// `encodedReplacementCharacter` if the scalar can't be represented in this
|
||||
/// encoding.
|
||||
public static func transcode<FromEncoding : UnicodeEncoding>(
|
||||
_ content: FromEncoding.EncodedScalar, from _: FromEncoding.Type
|
||||
) -> EncodedScalar {
|
||||
|
||||
Reference in New Issue
Block a user