diff --git a/TransmitTextEdit.cpp b/TransmitTextEdit.cpp index df1dee1..016e280 100644 --- a/TransmitTextEdit.cpp +++ b/TransmitTextEdit.cpp @@ -1,5 +1,6 @@ #include "TransmitTextEdit.h" +#include "commons.h" #include "varicode.h" #include @@ -244,12 +245,18 @@ void TransmitTextEdit::on_textContentsChanged(int /*pos*/, int rem, int add){ return; } +#if JS8_ALLOW_EXTENDED + QString normalized = text; +#else QString normalized = text.normalized(QString::NormalizationForm_KD); +#endif QString result; std::copy_if(normalized.begin(), normalized.end(), std::back_inserter(result), [](QChar& c) { #if JS8_ALLOW_UNICODE return (c == 10 || c == 0x1A || (c > 31 && c < 128)) || c.isPrint()); +#elif JS8_ALLOW_EXTENDED + return c.toLatin1() != 0 && (c == 10 || c == 0x1A || (c > 31 && c < 128) || Varicode::extendedChars().contains(c.toUpper())); #else return c.toLatin1() != 0 && (c == 10 || c == 0x1A || (c > 31 && c < 128)); #endif diff --git a/commons.h b/commons.h index d8a8d01..1224119 100644 --- a/commons.h +++ b/commons.h @@ -11,6 +11,7 @@ #define JS8_RING_BUFFER 1 // use a ring buffer instead of clearing the decode frames #define JS8_SINGLE_DECODE 0 // single submode decode per instantiation of the decoder #define JS8_DECODE_THREAD 1 // use a separate thread for decode process handling +#define JS8_ALLOW_EXTENDED 1 // allow extended latin-1 capital charset #ifdef QT_DEBUG #define JS8_DEBUG_DECODE 1 // emit debug statements for the decode pipeline diff --git a/jsc.cpp b/jsc.cpp index fe86a12..7283f60 100644 --- a/jsc.cpp +++ b/jsc.cpp @@ -152,7 +152,8 @@ QString JSC::decompress(Codeword const& bitvec){ break; } - auto word = QString(JSC::map[j].str); + // map is in latin1 format, not utf-8 + auto word = QLatin1String(JSC::map[j].str); out.append(word); if(!separators.isEmpty() && separators.first() == start + k){ diff --git a/jsc.h b/jsc.h index b46d005..09fd2c1 100644 --- a/jsc.h +++ b/jsc.h @@ -40,8 +40,8 @@ public: static const Tuple map[262144]; static const Tuple list[262144]; - static const quint32 prefixSize = 71; - static const Tuple prefix[71]; + static const quint32 prefixSize = 103; + static const Tuple prefix[103]; }; #endif // JSC_H diff --git a/jsc_list.cpp b/jsc_list.cpp index 22400a4..524e1e4 100644 --- a/jsc_list.cpp +++ b/jsc_list.cpp @@ -61083,7 +61083,7 @@ const Tuple JSC::list[262144] = { {"ROSIERE", 7, 190612}, {"ROSIER", 6, 168300}, {"ROSIE", 5, 49485}, - {"ROSIDS", 6, 262143}, + {"ROSIDS", 6, 262143}, {"ROSICRUCIAN", 11, 159215}, {"ROSHOLT", 7, 221740}, {"ROSHO", 5, 245639}, @@ -239508,38 +239508,38 @@ const Tuple JSC::list[262144] = { {"BO94", 4, 10738}, {"BO93", 4, 10737}, {"BO92", 4, 10736}, - {"BO91", 4, 10735}, - {"BO90", 4, 10734}, - {"BO89", 4, 10733}, - {"BO88", 4, 10732}, - {"BO87", 4, 10731}, - {"BO86", 4, 10730}, - {"BO85", 4, 10729}, - {"BO84", 4, 10728}, - {"BO83", 4, 10727}, - {"BO82", 4, 10726}, - {"BO81", 4, 10725}, - {"BO80", 4, 10724}, - {"BO79", 4, 10723}, - {"BO78", 4, 10722}, - {"BO77", 4, 10721}, - {"BO76", 4, 10720}, - {"BO75", 4, 10719}, - {"BO74", 4, 10718}, - {"BO73", 4, 10717}, - {"BO72", 4, 10716}, - {"BO71", 4, 10715}, - {"BO70", 4, 10714}, - {"BO69", 4, 10713}, - {"BO68", 4, 10712}, - {"BO67", 4, 10711}, - {"BO66", 4, 10710}, - {"BO65", 4, 10709}, - {"BO64", 4, 10708}, - {"BO63", 4, 10707}, - {"BO62", 4, 10706}, - {"BO61", 4, 10705}, - {"BO60", 4, 10704}, + {"\xde" /* Þ - "BO91" */, 1, 10735}, + {"\xdd" /* Ý - "BO90" */, 1, 10734}, + {"\xdc" /* Ü - "BO89" */, 1, 10733}, + {"\xdb" /* Û - "BO88" */, 1, 10732}, + {"\xda" /* Ú - "BO87" */, 1, 10731}, + {"\xd9" /* Ù - "BO86" */, 1, 10730}, + {"\xd8" /* Ø - "BO85" */, 1, 10729}, + {"\xd6" /* Ö - "BO84" */, 1, 10728}, + {"\xd5" /* Õ - "BO83" */, 1, 10727}, + {"\xd4" /* Ô - "BO82" */, 1, 10726}, + {"\xd3" /* Ó - "BO81" */, 1, 10725}, + {"\xd2" /* Ò - "BO80" */, 1, 10724}, + {"\xd1" /* Ñ - "BO79" */, 1, 10723}, + {"\xd0" /* Ð - "BO78" */, 1, 10722}, + {"\xcf" /* Ï - "BO77" */, 1, 10721}, + {"\xce" /* Î - "BO76" */, 1, 10720}, + {"\xcd" /* Í - "BO75" */, 1, 10719}, + {"\xcc" /* Ì - "BO74" */, 1, 10718}, + {"\xcb" /* Ë - "BO73" */, 1, 10717}, + {"\xca" /* Ê - "BO72" */, 1, 10716}, + {"\xc9" /* É - "BO71" */, 1, 10715}, + {"\xc8" /* È - "BO70" */, 1, 10714}, + {"\xc7" /* Ç - "BO69" */, 1, 10713}, + {"\xc6" /* Æ - "BO68" */, 1, 10712}, + {"\xc5" /* Å - "BO67" */, 1, 10711}, + {"\xc4" /* Ä - "BO66" */, 1, 10710}, + {"\xc3" /* Ã - "BO65" */, 1, 10709}, + {"\xc2" /* Â - "BO64" */, 1, 10708}, + {"\xc1" /* Á - "BO63" */, 1, 10707}, + {"\xc0" /* À - "BO62" */, 1, 10706}, + {"\xbf" /* ¿ - "BO61" */, 1, 10705}, + {"\xa1" /* ¡ - "BO60" */, 1, 10704}, {"BO59", 4, 10703}, {"BO58", 4, 10702}, {"BO57", 4, 10701}, @@ -262167,7 +262167,7 @@ const Tuple JSC::list[262144] = { {"!", 1, 28}, }; -const Tuple JSC::prefix[71] = { +const Tuple JSC::prefix[103] = { {"!", 1, 262143}, {"\"", 1, 262142}, {"#", 1, 262141}, @@ -262239,4 +262239,37 @@ const Tuple JSC::prefix[71] = { {"|", 1, 2}, {"}", 1, 1}, {"~", 1, 0}, + + {"\xa1" /* ¡ */, 1, 239518}, + {"\xbf" /* ¿ */, 1, 239517}, + {"\xc0" /* À */, 1, 239516}, + {"\xc1" /* Á */, 1, 239515}, + {"\xc2" /* Â */, 1, 239514}, + {"\xc3" /* Ã */, 1, 239513}, + {"\xc4" /* Ä */, 1, 239512}, + {"\xc5" /* Å */, 1, 239511}, + {"\xc6" /* Æ */, 1, 239510}, + {"\xc7" /* Ç */, 1, 239509}, + {"\xc8" /* È */, 1, 239508}, + {"\xc9" /* É */, 1, 239507}, + {"\xca" /* Ê */, 1, 239506}, + {"\xcb" /* Ë */, 1, 239505}, + {"\xcc" /* Ì */, 1, 239504}, + {"\xcd" /* Í */, 1, 239503}, + {"\xce" /* Î */, 1, 239502}, + {"\xcf" /* Ï */, 1, 239501}, + {"\xd0" /* Ð */, 1, 239500}, + {"\xd1" /* Ñ */, 1, 239499}, + {"\xd2" /* Ò */, 1, 239498}, + {"\xd3" /* Ó */, 1, 239497}, + {"\xd4" /* Ô */, 1, 239496}, + {"\xd5" /* Õ */, 1, 239495}, + {"\xd6" /* Ö */, 1, 239494}, + {"\xd8" /* Ø */, 1, 239493}, + {"\xd9" /* Ù */, 1, 239492}, + {"\xda" /* Ú */, 1, 239491}, + {"\xdb" /* Û */, 1, 239490}, + {"\xdc" /* Ü */, 1, 239489}, + {"\xdd" /* Ý */, 1, 239488}, + {"\xde" /* Þ */, 1, 239487}, }; diff --git a/jsc_map.cpp b/jsc_map.cpp index 56ea2e8..ad09898 100644 --- a/jsc_map.cpp +++ b/jsc_map.cpp @@ -10725,38 +10725,38 @@ const Tuple JSC::map[262144] = { {"BO57", 4, 10701}, {"BO58", 4, 10702}, {"BO59", 4, 10703}, - {"BO60", 4, 10704}, - {"BO61", 4, 10705}, - {"BO62", 4, 10706}, - {"BO63", 4, 10707}, - {"BO64", 4, 10708}, - {"BO65", 4, 10709}, - {"BO66", 4, 10710}, - {"BO67", 4, 10711}, - {"BO68", 4, 10712}, - {"BO69", 4, 10713}, - {"BO70", 4, 10714}, - {"BO71", 4, 10715}, - {"BO72", 4, 10716}, - {"BO73", 4, 10717}, - {"BO74", 4, 10718}, - {"BO75", 4, 10719}, - {"BO76", 4, 10720}, - {"BO77", 4, 10721}, - {"BO78", 4, 10722}, - {"BO79", 4, 10723}, - {"BO80", 4, 10724}, - {"BO81", 4, 10725}, - {"BO82", 4, 10726}, - {"BO83", 4, 10727}, - {"BO84", 4, 10728}, - {"BO85", 4, 10729}, - {"BO86", 4, 10730}, - {"BO87", 4, 10731}, - {"BO88", 4, 10732}, - {"BO89", 4, 10733}, - {"BO90", 4, 10734}, - {"BO91", 4, 10735}, + {"\xa1" /* ¡ - "BO60" */, 1, 10704}, + {"\xbf" /* ¿ - "BO61" */, 1, 10705}, + {"\xc0" /* À - "BO62" */, 1, 10706}, + {"\xc1" /* Á - "BO63" */, 1, 10707}, + {"\xc2" /* Â - "BO64" */, 1, 10708}, + {"\xc3" /* Ã - "BO65" */, 1, 10709}, + {"\xc4" /* Ä - "BO66" */, 1, 10710}, + {"\xc5" /* Å - "BO67" */, 1, 10711}, + {"\xc6" /* Æ - "BO68" */, 1, 10712}, + {"\xc7" /* Ç - "BO69" */, 1, 10713}, + {"\xc8" /* È - "BO70" */, 1, 10714}, + {"\xc9" /* É - "BO71" */, 1, 10715}, + {"\xca" /* Ê - "BO72" */, 1, 10716}, + {"\xcb" /* Ë - "BO73" */, 1, 10717}, + {"\xcc" /* Ì - "BO74" */, 1, 10718}, + {"\xcd" /* Í - "BO75" */, 1, 10719}, + {"\xce" /* Î - "BO76" */, 1, 10720}, + {"\xcf" /* Ï - "BO77" */, 1, 10721}, + {"\xd0" /* Ð - "BO78" */, 1, 10722}, + {"\xd1" /* Ñ - "BO79" */, 1, 10723}, + {"\xd2" /* Ò - "BO80" */, 1, 10724}, + {"\xd3" /* Ó - "BO81" */, 1, 10725}, + {"\xd4" /* Ô - "BO82" */, 1, 10726}, + {"\xd5" /* Õ - "BO83" */, 1, 10727}, + {"\xd6" /* Ö - "BO84" */, 1, 10728}, + {"\xd8" /* Ø - "BO85" */, 1, 10729}, + {"\xd9" /* Ù - "BO86" */, 1, 10730}, + {"\xda" /* Ú - "BO87" */, 1, 10731}, + {"\xdb" /* Û - "BO88" */, 1, 10732}, + {"\xdc" /* Ü - "BO89" */, 1, 10733}, + {"\xdd" /* Ý - "BO90" */, 1, 10734}, + {"\xde" /* Þ - "BO91" */, 1, 10735}, {"BO92", 4, 10736}, {"BO93", 4, 10737}, {"BO94", 4, 10738}, @@ -262164,5 +262164,5 @@ const Tuple JSC::map[262144] = { {"YANAI", 5, 262140}, {"YOGIBEAR", 8, 262141}, {"UWED", 4, 262142}, - {"ROSIDS", 6, 262143}, + {"ROSIDS", 1, 262143}, }; diff --git a/varicode.cpp b/varicode.cpp index b905967..2447260 100644 --- a/varicode.cpp +++ b/varicode.cpp @@ -335,6 +335,17 @@ int dbmTomwatts(int dbm){ return iter.value(); } +QString Varicode::extendedChars(){ + static QString c; + if(c.size() == 0){ + for(int i = 0; i < JSC::prefixSize; i++){ + if(JSC::prefix[i].size != 1){ continue; } + c.append(QLatin1String(JSC::prefix[i].str, 1)); + } + } + return c; +} + QString Varicode::escape(const QString &text){ static const int size = 6; QString escaped; diff --git a/varicode.h b/varicode.h index d9dedcd..99b6d1e 100644 --- a/varicode.h +++ b/varicode.h @@ -78,6 +78,8 @@ public: //Varicode(); + static QString extendedChars(); + static QString escape(const QString &text); static QString unescape(const QString &text);