-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added emoji String & Character extensions
- Loading branch information
1 parent
04ab66e
commit 429f232
Showing
3 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Julian Gerhards on 09.06.22. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension Character { | ||
/// A simple emoji is one scalar and presented to the user as an Emoji | ||
@available(iOS 10.2, *) | ||
var isSimpleEmoji: Bool { | ||
guard let firstScalar = unicodeScalars.first else { return false } | ||
return firstScalar.properties.isEmoji && firstScalar.value > 0x238C | ||
} | ||
|
||
/// Checks if the scalars will be merged into an emoji | ||
@available(iOS 10.2, *) | ||
var isCombinedIntoEmoji: Bool { unicodeScalars.count > 1 && unicodeScalars.first?.properties.isEmoji ?? false } | ||
|
||
@available(iOS 10.2, *) | ||
var isEmoji: Bool { isSimpleEmoji || isCombinedIntoEmoji } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters