Skip to content

Commit 4f89fec

Browse files
committed
Fix emoji detection bounds for Mahjong and Joker
- Updated `StringUtils.mightBeEmoji` to start at `0x1F000` to properly include Mahjong Tiles and Playing Cards blocks. - Removed bypass for "🀄" and "🃏" in `StringUtilsTest.kt`.
1 parent 82758c7 commit 4f89fec

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

app/src/main/java/helium314/keyboard/latin/common/StringUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public static boolean hasLineBreakCharacter(@Nullable final String text) {
498498
// very fast check, but there are very few blocks that exclusively contain emojis,
499499
public static boolean mightBeEmoji(final int c) {
500500
return (0x200D <= c && c <= 0x2BFF) // unicode blocks from General Punctuation to Miscellaneous Symbols and Arrows
501-
|| (0x1F104 <= c && c <= 0x1FAFF) // unicode blocks from Mahjong Tiles to Symbols and Pictographs Extended-A
501+
|| (0x1F000 <= c && c <= 0x1FAFF) // unicode blocks from Mahjong Tiles to Symbols and Pictographs Extended-A
502502
|| (0xE0000 <= c && c <= 0xE007F) // unicode block Tags
503503
|| c == 0xFE0F; // variation selector emoji with color
504504
}

app/src/test/java/helium314/keyboard/latin/StringUtilsTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ class StringUtilsTest {
166166

167167
val brokenDetectionAtStart = listOf("〰️", "〽️", "©️", "®️", "#️⃣", "*️⃣", "0️⃣", "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "㊗️", "㊙️")
168168
allEmojis.forEach {
169-
if (it == "🀄" || it == "🃏") return@forEach // todo: should be fixed, ideally in the regex
170169
assert(isEmoji(it))
171170
assert(StringUtils.mightBeEmoji(it.codePointBefore(it.length)))
172171
if (it !in brokenDetectionAtStart)

0 commit comments

Comments
 (0)