Add support for iOS 15 and unicode release v13 (#1)
This commit is contained in:
committed by
GitHub
parent
6bbb3a1a71
commit
977c01327f
33
Sources/EmojiSourceKit/StringHelper.swift
Normal file
33
Sources/EmojiSourceKit/StringHelper.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// StringHelper.swift
|
||||
//
|
||||
//
|
||||
// Created by Niklas Amslgruber on 10.06.23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension String {
|
||||
|
||||
func trim() -> String {
|
||||
return self.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
func asEmoji() -> String? {
|
||||
guard let unicodeNumber = Int(self, radix: 16), let unicode = Unicode.Scalar(unicodeNumber) else {
|
||||
return nil
|
||||
}
|
||||
return String(unicode)
|
||||
}
|
||||
}
|
||||
|
||||
extension String.SubSequence {
|
||||
|
||||
func trim() -> String {
|
||||
return String(self).trim()
|
||||
}
|
||||
|
||||
func asEmoji() -> String? {
|
||||
return String(self).asEmoji()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user