IME // Add UniChar.isPrintable()
This commit is contained in:
parent
f11063fbb0
commit
82707e89b6
|
@ -364,7 +364,7 @@ extension String: LocalizedError {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: - Ensuring trailing slash of a string:
|
||||
// MARK: - Ensuring trailing slash of a string
|
||||
|
||||
extension String {
|
||||
mutating func ensureTrailingSlash() {
|
||||
|
@ -373,3 +373,16 @@ extension String {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CharCode printability check
|
||||
|
||||
// Ref: https://forums.swift.org/t/57085/5
|
||||
extension UniChar {
|
||||
public func isPrintable() -> Bool {
|
||||
guard Unicode.Scalar(UInt32(self)) != nil else {
|
||||
struct NotAWholeScalar: Error {}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue