Fixed #245: Added partial support for a subset of latin1 charset

This commit is contained in:
Jordan Sherer 2019-11-22 01:34:57 -05:00
parent 1f7d6a9f3a
commit 138063a112
8 changed files with 125 additions and 70 deletions

View File

@ -1,5 +1,6 @@
#include "TransmitTextEdit.h" #include "TransmitTextEdit.h"
#include "commons.h"
#include "varicode.h" #include "varicode.h"
#include <iterator> #include <iterator>
@ -244,12 +245,18 @@ void TransmitTextEdit::on_textContentsChanged(int /*pos*/, int rem, int add){
return; return;
} }
#if JS8_ALLOW_EXTENDED
QString normalized = text;
#else
QString normalized = text.normalized(QString::NormalizationForm_KD); QString normalized = text.normalized(QString::NormalizationForm_KD);
#endif
QString result; QString result;
std::copy_if(normalized.begin(), normalized.end(), std::back_inserter(result), [](QChar& c) { std::copy_if(normalized.begin(), normalized.end(), std::back_inserter(result), [](QChar& c) {
#if JS8_ALLOW_UNICODE #if JS8_ALLOW_UNICODE
return (c == 10 || c == 0x1A || (c > 31 && c < 128)) || c.isPrint()); 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 #else
return c.toLatin1() != 0 && (c == 10 || c == 0x1A || (c > 31 && c < 128)); return c.toLatin1() != 0 && (c == 10 || c == 0x1A || (c > 31 && c < 128));
#endif #endif

View File

@ -11,6 +11,7 @@
#define JS8_RING_BUFFER 1 // use a ring buffer instead of clearing the decode frames #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_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_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 #ifdef QT_DEBUG
#define JS8_DEBUG_DECODE 1 // emit debug statements for the decode pipeline #define JS8_DEBUG_DECODE 1 // emit debug statements for the decode pipeline

View File

@ -152,7 +152,8 @@ QString JSC::decompress(Codeword const& bitvec){
break; 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); out.append(word);
if(!separators.isEmpty() && separators.first() == start + k){ if(!separators.isEmpty() && separators.first() == start + k){

4
jsc.h
View File

@ -40,8 +40,8 @@ public:
static const Tuple map[262144]; static const Tuple map[262144];
static const Tuple list[262144]; static const Tuple list[262144];
static const quint32 prefixSize = 71; static const quint32 prefixSize = 103;
static const Tuple prefix[71]; static const Tuple prefix[103];
}; };
#endif // JSC_H #endif // JSC_H

View File

@ -61083,7 +61083,7 @@ const Tuple JSC::list[262144] = {
{"ROSIERE", 7, 190612}, {"ROSIERE", 7, 190612},
{"ROSIER", 6, 168300}, {"ROSIER", 6, 168300},
{"ROSIE", 5, 49485}, {"ROSIE", 5, 49485},
{"ROSIDS", 6, 262143}, {"ROSIDS", 6, 262143},
{"ROSICRUCIAN", 11, 159215}, {"ROSICRUCIAN", 11, 159215},
{"ROSHOLT", 7, 221740}, {"ROSHOLT", 7, 221740},
{"ROSHO", 5, 245639}, {"ROSHO", 5, 245639},
@ -239508,38 +239508,38 @@ const Tuple JSC::list[262144] = {
{"BO94", 4, 10738}, {"BO94", 4, 10738},
{"BO93", 4, 10737}, {"BO93", 4, 10737},
{"BO92", 4, 10736}, {"BO92", 4, 10736},
{"BO91", 4, 10735}, {"\xde" /* Þ - "BO91" */, 1, 10735},
{"BO90", 4, 10734}, {"\xdd" /* Ý - "BO90" */, 1, 10734},
{"BO89", 4, 10733}, {"\xdc" /* Ü - "BO89" */, 1, 10733},
{"BO88", 4, 10732}, {"\xdb" /* Û - "BO88" */, 1, 10732},
{"BO87", 4, 10731}, {"\xda" /* Ú - "BO87" */, 1, 10731},
{"BO86", 4, 10730}, {"\xd9" /* Ù - "BO86" */, 1, 10730},
{"BO85", 4, 10729}, {"\xd8" /* Ø - "BO85" */, 1, 10729},
{"BO84", 4, 10728}, {"\xd6" /* Ö - "BO84" */, 1, 10728},
{"BO83", 4, 10727}, {"\xd5" /* Õ - "BO83" */, 1, 10727},
{"BO82", 4, 10726}, {"\xd4" /* Ô - "BO82" */, 1, 10726},
{"BO81", 4, 10725}, {"\xd3" /* Ó - "BO81" */, 1, 10725},
{"BO80", 4, 10724}, {"\xd2" /* Ò - "BO80" */, 1, 10724},
{"BO79", 4, 10723}, {"\xd1" /* Ñ - "BO79" */, 1, 10723},
{"BO78", 4, 10722}, {"\xd0" /* Ð - "BO78" */, 1, 10722},
{"BO77", 4, 10721}, {"\xcf" /* Ï - "BO77" */, 1, 10721},
{"BO76", 4, 10720}, {"\xce" /* Î - "BO76" */, 1, 10720},
{"BO75", 4, 10719}, {"\xcd" /* Í - "BO75" */, 1, 10719},
{"BO74", 4, 10718}, {"\xcc" /* Ì - "BO74" */, 1, 10718},
{"BO73", 4, 10717}, {"\xcb" /* Ë - "BO73" */, 1, 10717},
{"BO72", 4, 10716}, {"\xca" /* Ê - "BO72" */, 1, 10716},
{"BO71", 4, 10715}, {"\xc9" /* É - "BO71" */, 1, 10715},
{"BO70", 4, 10714}, {"\xc8" /* È - "BO70" */, 1, 10714},
{"BO69", 4, 10713}, {"\xc7" /* Ç - "BO69" */, 1, 10713},
{"BO68", 4, 10712}, {"\xc6" /* Æ - "BO68" */, 1, 10712},
{"BO67", 4, 10711}, {"\xc5" /* Å - "BO67" */, 1, 10711},
{"BO66", 4, 10710}, {"\xc4" /* Ä - "BO66" */, 1, 10710},
{"BO65", 4, 10709}, {"\xc3" /* Ã - "BO65" */, 1, 10709},
{"BO64", 4, 10708}, {"\xc2" /* Â - "BO64" */, 1, 10708},
{"BO63", 4, 10707}, {"\xc1" /* Á - "BO63" */, 1, 10707},
{"BO62", 4, 10706}, {"\xc0" /* À - "BO62" */, 1, 10706},
{"BO61", 4, 10705}, {"\xbf" /* ¿ - "BO61" */, 1, 10705},
{"BO60", 4, 10704}, {"\xa1" /* ¡ - "BO60" */, 1, 10704},
{"BO59", 4, 10703}, {"BO59", 4, 10703},
{"BO58", 4, 10702}, {"BO58", 4, 10702},
{"BO57", 4, 10701}, {"BO57", 4, 10701},
@ -262167,7 +262167,7 @@ const Tuple JSC::list[262144] = {
{"!", 1, 28}, {"!", 1, 28},
}; };
const Tuple JSC::prefix[71] = { const Tuple JSC::prefix[103] = {
{"!", 1, 262143}, {"!", 1, 262143},
{"\"", 1, 262142}, {"\"", 1, 262142},
{"#", 1, 262141}, {"#", 1, 262141},
@ -262239,4 +262239,37 @@ const Tuple JSC::prefix[71] = {
{"|", 1, 2}, {"|", 1, 2},
{"}", 1, 1}, {"}", 1, 1},
{"~", 1, 0}, {"~", 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},
}; };

View File

@ -10725,38 +10725,38 @@ const Tuple JSC::map[262144] = {
{"BO57", 4, 10701}, {"BO57", 4, 10701},
{"BO58", 4, 10702}, {"BO58", 4, 10702},
{"BO59", 4, 10703}, {"BO59", 4, 10703},
{"BO60", 4, 10704}, {"\xa1" /* ¡ - "BO60" */, 1, 10704},
{"BO61", 4, 10705}, {"\xbf" /* ¿ - "BO61" */, 1, 10705},
{"BO62", 4, 10706}, {"\xc0" /* À - "BO62" */, 1, 10706},
{"BO63", 4, 10707}, {"\xc1" /* Á - "BO63" */, 1, 10707},
{"BO64", 4, 10708}, {"\xc2" /* Â - "BO64" */, 1, 10708},
{"BO65", 4, 10709}, {"\xc3" /* Ã - "BO65" */, 1, 10709},
{"BO66", 4, 10710}, {"\xc4" /* Ä - "BO66" */, 1, 10710},
{"BO67", 4, 10711}, {"\xc5" /* Å - "BO67" */, 1, 10711},
{"BO68", 4, 10712}, {"\xc6" /* Æ - "BO68" */, 1, 10712},
{"BO69", 4, 10713}, {"\xc7" /* Ç - "BO69" */, 1, 10713},
{"BO70", 4, 10714}, {"\xc8" /* È - "BO70" */, 1, 10714},
{"BO71", 4, 10715}, {"\xc9" /* É - "BO71" */, 1, 10715},
{"BO72", 4, 10716}, {"\xca" /* Ê - "BO72" */, 1, 10716},
{"BO73", 4, 10717}, {"\xcb" /* Ë - "BO73" */, 1, 10717},
{"BO74", 4, 10718}, {"\xcc" /* Ì - "BO74" */, 1, 10718},
{"BO75", 4, 10719}, {"\xcd" /* Í - "BO75" */, 1, 10719},
{"BO76", 4, 10720}, {"\xce" /* Î - "BO76" */, 1, 10720},
{"BO77", 4, 10721}, {"\xcf" /* Ï - "BO77" */, 1, 10721},
{"BO78", 4, 10722}, {"\xd0" /* Ð - "BO78" */, 1, 10722},
{"BO79", 4, 10723}, {"\xd1" /* Ñ - "BO79" */, 1, 10723},
{"BO80", 4, 10724}, {"\xd2" /* Ò - "BO80" */, 1, 10724},
{"BO81", 4, 10725}, {"\xd3" /* Ó - "BO81" */, 1, 10725},
{"BO82", 4, 10726}, {"\xd4" /* Ô - "BO82" */, 1, 10726},
{"BO83", 4, 10727}, {"\xd5" /* Õ - "BO83" */, 1, 10727},
{"BO84", 4, 10728}, {"\xd6" /* Ö - "BO84" */, 1, 10728},
{"BO85", 4, 10729}, {"\xd8" /* Ø - "BO85" */, 1, 10729},
{"BO86", 4, 10730}, {"\xd9" /* Ù - "BO86" */, 1, 10730},
{"BO87", 4, 10731}, {"\xda" /* Ú - "BO87" */, 1, 10731},
{"BO88", 4, 10732}, {"\xdb" /* Û - "BO88" */, 1, 10732},
{"BO89", 4, 10733}, {"\xdc" /* Ü - "BO89" */, 1, 10733},
{"BO90", 4, 10734}, {"\xdd" /* Ý - "BO90" */, 1, 10734},
{"BO91", 4, 10735}, {"\xde" /* Þ - "BO91" */, 1, 10735},
{"BO92", 4, 10736}, {"BO92", 4, 10736},
{"BO93", 4, 10737}, {"BO93", 4, 10737},
{"BO94", 4, 10738}, {"BO94", 4, 10738},
@ -262164,5 +262164,5 @@ const Tuple JSC::map[262144] = {
{"YANAI", 5, 262140}, {"YANAI", 5, 262140},
{"YOGIBEAR", 8, 262141}, {"YOGIBEAR", 8, 262141},
{"UWED", 4, 262142}, {"UWED", 4, 262142},
{"ROSIDS", 6, 262143}, {"ROSIDS", 1, 262143},
}; };

View File

@ -335,6 +335,17 @@ int dbmTomwatts(int dbm){
return iter.value(); 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){ QString Varicode::escape(const QString &text){
static const int size = 6; static const int size = 6;
QString escaped; QString escaped;

View File

@ -78,6 +78,8 @@ public:
//Varicode(); //Varicode();
static QString extendedChars();
static QString escape(const QString &text); static QString escape(const QString &text);
static QString unescape(const QString &text); static QString unescape(const QString &text);