Review fixes: - Keep stored message history beyond the 200-message window; stop messages leaking between radios; reset link/session state on disconnect - Accept firmware's 176-byte RX frames over USB/TCP - Hold APP_START during contact sync; contact-sync watchdog; replay DMs from not-yet-known senders; tombstone late command replies; finish channel sync on ERR_NOT_FOUND; fail region-scoped sends cleanly - DM retry watchdog when RESP_CODE_SENT never arrives; late repeater CLI replies; ACK hash collisions; UTF-8-safe name truncation - Image pipeline: delete-during-decode, lifecycle cancels, decoder memory release, entry cap, dead worker recovery, atomic model writes - Storage: deterministic reaction hash across web/native, Smaz double-decode, per-entry parsing, per-radio path history and regions, review-mode data isolation - UI: safe channel slot selection, byte-length name limits, double-send guard, mounted checks, localized hardcoded strings - Skip persisted-store reload on repeat SELF_INFO Features: - Radio default flood scope (firmware ver 11+) and explicit unscoped sends (ver 12+) - Scan for nearby nodes (#570) - Optional distinct first-hop repeater counting for channel resend (#589) - Optional region next to hop count (#580) Issues: - Message text follows system font size (#569) - Repeater/room password field accepts 20 chars (#576) - TCP auto-reconnect and keepalive (#571) - Order feeds by local receive time; flag future timestamps (#584) - Coding rate help text (#568), French "Favoris" (#575) - iOS/macOS app badge now clears Translations for all new strings in every locale.
66 lines
1.4 KiB
Dart
66 lines
1.4 KiB
Dart
class Cyr2Lat {
|
||
static Map<String, String> _charMap = {
|
||
'А': 'A',
|
||
'В': 'B',
|
||
'Е': 'E',
|
||
'Ё': 'E',
|
||
'З': '3',
|
||
'К': 'K',
|
||
'М': 'M',
|
||
'Н': 'H',
|
||
'О': 'O',
|
||
'Р': 'P',
|
||
'С': 'C',
|
||
'Т': 'T',
|
||
'Х': 'X',
|
||
'Ь': 'b',
|
||
'а': 'a',
|
||
'е': 'e',
|
||
'ё': 'e',
|
||
'о': 'o',
|
||
'р': 'p',
|
||
'с': 'c',
|
||
'у': 'y',
|
||
'х': 'x',
|
||
};
|
||
|
||
// Non-greedy so only the leading "@[name] " mention is treated as the
|
||
// sender prefix, not everything up to the last "] " in the message.
|
||
static final RegExp _prefixRegExp = RegExp(r'@\[[\S\s]+?\] ');
|
||
|
||
static void setCharMap(Map<String, String> charMap) {
|
||
_charMap = Map.from(charMap);
|
||
}
|
||
|
||
static String encode(String text) {
|
||
if (text.isEmpty) return text;
|
||
final buffer = StringBuffer();
|
||
|
||
final senderName = extractSenderName(text);
|
||
final msgText = removeSenderName(text);
|
||
|
||
for (final rune in msgText.runes) {
|
||
final char = String.fromCharCode(rune);
|
||
buffer.write(_charMap[char] ?? char);
|
||
}
|
||
|
||
return senderName + buffer.toString();
|
||
}
|
||
|
||
static String removeSenderName(String text) {
|
||
final match = _prefixRegExp.matchAsPrefix(text);
|
||
if (match != null) {
|
||
return text.substring(match.end);
|
||
}
|
||
return text;
|
||
}
|
||
|
||
static String extractSenderName(String text) {
|
||
final match = _prefixRegExp.matchAsPrefix(text);
|
||
if (match != null) {
|
||
return match.group(0) ?? '';
|
||
}
|
||
return '';
|
||
}
|
||
}
|