Skip to content

Commit 48aa73d

Browse files
committed
add emoji checking/parsing, bump to 0.0.11
1 parent 629ad35 commit 48aa73d

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1414
# Kotlin code style for this project: "official" or "obsolete":
1515
kotlin.code.style=official
1616
android.useAndroidX=true
17-
projectVersion=0.0.10
17+
projectVersion=0.0.11
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.thelightphone.lp3Keyboard.ui
2+
3+
fun isEmojiCodePoint(cp: Int): Boolean {
4+
// ZWJ and variation selector-16 are combiners, not standalone glyphs.
5+
if (cp == 0x200D || cp == 0xFE0F) return false
6+
return cp in 0x1F000..0x1FFFF || // Most modern emoji (supplementary plane)
7+
cp in 0x2300..0x23FF || // Misc Technical (⌚ ⌛ ⏰ …)
8+
cp in 0x2600..0x27BF || // Misc Symbols, Dingbats (☀ ✨ ❤ …)
9+
cp in 0x2B00..0x2BFF // Misc Symbols & Arrows
10+
}
11+
12+
fun parseEmojiString(allEmojis: String?): List<Int>? {
13+
if (allEmojis == null) return null
14+
val codePoints = mutableListOf<Int>()
15+
var i = 0
16+
while (i < allEmojis.length) {
17+
val cp = allEmojis.codePointAt(i)
18+
if (isEmojiCodePoint(cp)) codePoints.add(cp)
19+
i += Character.charCount(cp)
20+
}
21+
return codePoints
22+
}

0 commit comments

Comments
 (0)