meshcore-open/lib/utils/emoji_utils.dart
zach e7a5b9e209 Initial commit: MeshCore Open Flutter client
Open-source Flutter client for MeshCore LoRa mesh networking devices.

Features:
- BLE device scanning and connection
- Nordic UART Service (NUS) integration
- Material 3 design with system theme support
- Provider-based state management
- Placeholder screens for chat, contacts, and settings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-26 11:42:02 -07:00

33 lines
1,016 B
Dart

import 'package:characters/characters.dart';
String? firstEmoji(String name) {
if (name.isEmpty) return null;
for (final cluster in name.characters) {
if (_containsEmoji(cluster)) {
return cluster;
}
}
return null;
}
bool _containsEmoji(String cluster) {
for (final rune in cluster.runes) {
if (_isEmojiRune(rune)) return true;
}
return false;
}
bool _isEmojiRune(int rune) {
if (rune == 0x00A9 || rune == 0x00AE) return true;
if (rune == 0x203C || rune == 0x2049) return true;
if (rune == 0x2122 || rune == 0x2139) return true;
if (rune >= 0x2194 && rune <= 0x21AA) return true;
if (rune >= 0x2300 && rune <= 0x23FF) return true;
if (rune >= 0x2460 && rune <= 0x24FF) return true;
if (rune >= 0x25A0 && rune <= 0x27BF) return true;
if (rune >= 0x2900 && rune <= 0x297F) return true;
if (rune >= 0x2B00 && rune <= 0x2BFF) return true;
if (rune >= 0x1F000 && rune <= 0x1FAFF) return true;
if (rune >= 0x1FC00 && rune <= 0x1FFFD) return true;
return false;
}