mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Respond to CR.
// FREEBIE
This commit is contained in:
parent
563eed6c6e
commit
c6047b72b4
1 changed files with 0 additions and 50 deletions
|
@ -228,56 +228,6 @@ extension String {
|
|||
&& !$0.isZeroWidthJoiner
|
||||
})
|
||||
}
|
||||
|
||||
// The next tricks are mostly to demonstrate how tricky it can be to determine emoji's
|
||||
// If anyone has suggestions how to improve this, please let me know
|
||||
var emojiString: String {
|
||||
|
||||
return emojiScalars.map { String($0) }.reduce("", +)
|
||||
}
|
||||
|
||||
var emojis: [String] {
|
||||
|
||||
var scalars: [[UnicodeScalar]] = []
|
||||
var currentScalarSet: [UnicodeScalar] = []
|
||||
var previousScalar: UnicodeScalar?
|
||||
|
||||
for scalar in emojiScalars {
|
||||
|
||||
if let prev = previousScalar, !prev.isZeroWidthJoiner && !scalar.isZeroWidthJoiner {
|
||||
|
||||
scalars.append(currentScalarSet)
|
||||
currentScalarSet = []
|
||||
}
|
||||
currentScalarSet.append(scalar)
|
||||
|
||||
previousScalar = scalar
|
||||
}
|
||||
|
||||
scalars.append(currentScalarSet)
|
||||
|
||||
return scalars.map { $0.map { String($0) } .reduce("", +) }
|
||||
}
|
||||
|
||||
fileprivate var emojiScalars: [UnicodeScalar] {
|
||||
|
||||
var chars: [UnicodeScalar] = []
|
||||
var previous: UnicodeScalar?
|
||||
for cur in unicodeScalars {
|
||||
|
||||
if let previous = previous, previous.isZeroWidthJoiner && cur.isEmoji {
|
||||
chars.append(previous)
|
||||
chars.append(cur)
|
||||
|
||||
} else if cur.isEmoji {
|
||||
chars.append(cur)
|
||||
}
|
||||
|
||||
previous = cur
|
||||
}
|
||||
|
||||
return chars
|
||||
}
|
||||
}
|
||||
|
||||
@objc class DisplayableText: NSObject {
|
||||
|
|
Loading…
Reference in a new issue