Skip to content

Commit

Permalink
remove encoding, fixed encoding data from formats. (GPSBabel#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 authored Jan 6, 2023
1 parent 2be4547 commit aac3c51
Show file tree
Hide file tree
Showing 46 changed files with 71 additions and 357 deletions.
5 changes: 3 additions & 2 deletions brauniger_iq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ static void data_read()
static QVector<arglist_t> brauniger_iq_args = {
};

/* master process: don't convert anything */

ff_vecs_t brauniger_iq_vecs = {
ff_type_serial,
{ ff_cap_none, ff_cap_read, ff_cap_none},
Expand All @@ -274,6 +276,5 @@ ff_vecs_t brauniger_iq_vecs = {
nullptr,
nullptr,
&brauniger_iq_args,
CET_CHARSET_UTF8, 1 /* master process: don't convert anything | CET-REVIEW */
, NULL_POS_OPS
NULL_POS_OPS
};
10 changes: 0 additions & 10 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,6 @@ struct ff_vecs_t {
ff_write write;
ff_exit exit;
QVector<arglist_t>* args;
QString encode;
int fixed_encode;
position_ops_t position_ops;
};

Expand Down Expand Up @@ -988,14 +986,6 @@ QString pretty_deg_format(double lat, double lon, char fmt, const char* sep, boo

QString get_filename(const QString& fname); /* extract the filename portion */

/*
* Character encoding transformations.
*/

#define CET_CHARSET_ASCII "US-ASCII"
#define CET_CHARSET_UTF8 "UTF-8"
#define CET_CHARSET_MS_ANSI "windows-1252"

/* this lives in gpx.c */
gpsbabel::DateTime xml_parse_time(const QString& dateTimeString);

Expand Down
10 changes: 0 additions & 10 deletions dg-100.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ class Dg100Format : public Format
};
}

QString get_encode() const override
{
return CET_CHARSET_ASCII;
}

int get_fixed_encode() const override
{
return 0;
}

void read() override;
void rd_deinit() override;

Expand Down
12 changes: 1 addition & 11 deletions exif.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include <cstdint> // for uint32_t, uint16_t, uint8_t, int16_t, int32_t

#include "defs.h" // for arglist_t, ff_cap, Waypoint, ARG_NOMINMAX, ARGTYPE_BOOL, ff_cap_none, ARGTYPE_INT, ARGTYPE_STRING, CET_CHARSET_UTF8, ff_cap_read, ff_cap_write, ff_type, ff_type_file
#include "defs.h" // for arglist_t, ff_cap, Waypoint, ARG_NOMINMAX, ARGTYPE_BOOL, ff_cap_none, ARGTYPE_INT, ARGTYPE_STRING, ff_cap_read, ff_cap_write, ff_type, ff_type_file
#include "format.h" // for Format
#include "gbfile.h" // for gbfile, gbsize_t

Expand All @@ -73,16 +73,6 @@ class ExifFormat : public Format
};
}

QString get_encode() const override
{
return CET_CHARSET_UTF8;
}

int get_fixed_encode() const override
{
return 0;
}

void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override;
Expand Down
2 changes: 0 additions & 2 deletions format.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ class Format

virtual ff_type get_type() const = 0;
virtual QVector<ff_cap> get_cap() const = 0;
virtual QString get_encode() const = 0;
virtual int get_fixed_encode() const = 0;

QString get_name() const
{
Expand Down
5 changes: 1 addition & 4 deletions format_skeleton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ ff_vecs_t format_skeleton_vecs = {
format_skeleton_write,
format_skeleton_exit,
&format_skeleton_args,
CET_CHARSET_ASCII, 0, /* ascii is the expected character set */
/* not fixed, can be changed through command line parameter */
NULL_POS_OPS, // Unless you do realtime positioning
nullptr // name. Not used by modules.
NULL_POS_OPS // Unless you do realtime positioning

};
/**************************************************************************/
9 changes: 4 additions & 5 deletions garmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static void
rw_init(const QString& fname)
{
receiver_must_upper = 1;
const char* receiver_charset = CET_CHARSET_ASCII;
const char* receiver_charset = "US-ASCII";

if (!mkshort_handle) {
mkshort_handle = mkshort_new_handle();
Expand Down Expand Up @@ -268,7 +268,7 @@ rw_init(const QString& fname)
snwhiteopt = xstrdup("1");
receiver_must_upper = 0;
/* This might be 8859-1 */
receiver_charset = CET_CHARSET_MS_ANSI;
receiver_charset = "windows-1252";
break;
case 291: /* GPSMAP 60CS, probably others */
case 1095: /* GPS 72H */
Expand All @@ -280,15 +280,15 @@ rw_init(const QString& fname)
case 463: /* Quest 2 */
receiver_must_upper = 0;
receiver_short_length = 30;
receiver_charset = CET_CHARSET_MS_ANSI;
receiver_charset = "windows-1252";
break;
case 577: // Rino 530HCx Version 2.50
receiver_must_upper = 0;
receiver_short_length = 14;
break;
case 429: // Streetpilot i3
receiver_must_upper = 0;
receiver_charset = CET_CHARSET_MS_ANSI;
receiver_charset = "windows-1252";
receiver_short_length = 30;
break;
case 484: // Forerunner 305
Expand Down Expand Up @@ -1167,7 +1167,6 @@ ff_vecs_t garmin_vecs = {
data_write,
nullptr,
&garmin_args,
CET_CHARSET_ASCII, 0,
{ pvt_init, pvt_read, rw_deinit, nullptr, nullptr, nullptr }
};

Expand Down
10 changes: 0 additions & 10 deletions garmin_fit.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ class GarminFitFormat : public Format
};
}

QString get_encode() const override
{
return CET_CHARSET_ASCII;
}

int get_fixed_encode() const override
{
return 0;
}

void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override;
Expand Down
12 changes: 1 addition & 11 deletions garmin_gpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#include <cstdint> // for int32_t, int16_t, uint16_t
#include <ctime> // for time_t

#include "defs.h" // for arglist_t, ARG_NOMINMAX, ff_cap, Waypoint, ARGTYPE_BOOL, ARGTYPE_STRING, ff_cap_none, ARGTYPE_FILE, ARGTYPE_INT, CET_CHARSET_MS_ANSI, bounds, ff_cap_read, ff_cap_write, ff_type, ff_type_file, short_handle
#include "defs.h" // for arglist_t, ARG_NOMINMAX, ff_cap, Waypoint, ARGTYPE_BOOL, ARGTYPE_STRING, ff_cap_none, ARGTYPE_FILE, ARGTYPE_INT, bounds, ff_cap_read, ff_cap_write, ff_type, ff_type_file, short_handle
#include "format.h" // for Format
#include "garmin_fs.h" // for garmin_fs_t
#include "gbfile.h" // for gbfile
Expand Down Expand Up @@ -83,16 +83,6 @@ class GarminGPIFormat : public Format
};
}

QString get_encode() const override
{
return CET_CHARSET_MS_ANSI; /* WIN-CP1252 */
}

int get_fixed_encode() const override
{
return 0;
}

void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override;
Expand Down
22 changes: 11 additions & 11 deletions garmin_txt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ garmin_txt_wr_init(const QString& fname)
memset(&gtxt_flags, 0, sizeof(gtxt_flags));

fout = new gpsbabel::TextStream;
fout->open(fname, QIODevice::WriteOnly, MYNAME, "Windows-1252");
fout->open(fname, QIODevice::WriteOnly, MYNAME, "windows-1252");

gtxt_flags.metric = (toupper(*get_option_val(opt_dist, "m")) == 'M');
gtxt_flags.celsius = (toupper(*get_option_val(opt_temp, "c")) == 'C');
Expand Down Expand Up @@ -1348,7 +1348,7 @@ garmin_txt_rd_init(const QString& fname)
memset(&gtxt_flags, 0, sizeof(gtxt_flags));

fin = new gpsbabel::TextStream;
fin->open(fname, QIODevice::ReadOnly, MYNAME, "Windows-1252");
fin->open(fname, QIODevice::ReadOnly, MYNAME, "windows-1252");
memset(&header_ct, 0, sizeof(header_ct));

datum_index = -1;
Expand Down Expand Up @@ -1415,6 +1415,14 @@ garmin_txt_read()
}
}

/*
* The file encoding is windows-1252.
* Conversion between windows-1252 and utf-16 is handled by the stream.
* Conversion between utf-16 and utf-8 is handled by this format.
* Let main know char strings have already been converted to utf-8
* so it doesn't attempt to re-convert any char strings including gmsd data.
*/

ff_vecs_t garmin_txt_vecs = {
ff_type_file,
FF_CAP_RW_ALL,
Expand All @@ -1426,15 +1434,7 @@ ff_vecs_t garmin_txt_vecs = {
garmin_txt_write,
nullptr,
&garmin_txt_args,
/*
* The file encoding is Windows-1252, a.k.a CET_CHARSET_MS_ANSI.
* Conversion between Windows-1252 and utf-16 is handled by the stream.
* Conversion between utf-16 and utf-8 is handled by this format.
* Let main know char strings have already been converted to utf-8
* so it doesn't attempt to re-convert any char strings including gmsd data.
*/
CET_CHARSET_UTF8, 0
, NULL_POS_OPS
NULL_POS_OPS
};

#endif // CSVFMTS_ENABLED
7 changes: 4 additions & 3 deletions garmin_xt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ format_garmin_xt_read()

/**************************************************************************/

/* ascii is the expected character set */
/* not fixed, can be changed through command line parameter */

ff_vecs_t format_garmin_xt_vecs = {
ff_type_file,
{
Expand All @@ -421,8 +424,6 @@ ff_vecs_t format_garmin_xt_vecs = {
nullptr,
nullptr,
&format_garmin_xt_args,
CET_CHARSET_ASCII, 0 /* ascii is the expected character set */
/* not fixed, can be changed through command line parameter */
, NULL_POS_OPS
NULL_POS_OPS
};
/**************************************************************************/
13 changes: 1 addition & 12 deletions gdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <QString> // for QString
#include <QVector> // for QVector

#include "defs.h" // for arglist_t, Waypoint, route_head, ARGTYPE_BOOL, ARGTYPE_INT, ARG_NOMINMAX, bounds, CET_CHARSET_MS_ANSI, FF_CAP_RW_ALL, ff_cap, ff_type, ff_type_file, short_handle
#include "defs.h" // for arglist_t, Waypoint, route_head, ARGTYPE_BOOL, ARGTYPE_INT, ARG_NOMINMAX, bounds, FF_CAP_RW_ALL, ff_cap, ff_type, ff_type_file, short_handle
#include "format.h" // for Format
#include "garmin_fs.h" // for garmin_fs_t
#include "garmin_tables.h" // for gt_waypt_classes_e
Expand All @@ -55,17 +55,6 @@ class GdbFormat : public Format
return FF_CAP_RW_ALL;
}

QString get_encode() const override
{
return CET_CHARSET_MS_ANSI;
}

int get_fixed_encode() const override
{
/* O.K.: changed to NON-FIXED because of utf8 strings since GDB V3 */
return 0;
}

void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override;
Expand Down
1 change: 0 additions & 1 deletion geo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,5 @@ ff_vecs_t geo_vecs = {
geo_write,
nullptr,
&geo_args,
CET_CHARSET_UTF8, 0, /* CET-REVIEW */
NULL_POS_OPS
};
10 changes: 0 additions & 10 deletions geojson.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ class GeoJsonFormat : public Format
return FF_CAP_RW_ALL;
}

QString get_encode() const override
{
return CET_CHARSET_UTF8;
}

int get_fixed_encode() const override
{
return 0;
}

void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override;
Expand Down
10 changes: 0 additions & 10 deletions globalsat_sport.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ class GlobalsatSportFormat : public Format
};
}

QString get_encode() const override
{
return CET_CHARSET_ASCII;
}

int get_fixed_encode() const override
{
return 0;
}

void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override;
Expand Down
3 changes: 1 addition & 2 deletions gpssim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,5 @@ ff_vecs_t gpssim_vecs = {
gpssim_write,
nullptr,
&gpssim_args,
CET_CHARSET_ASCII, 0
, NULL_POS_OPS
NULL_POS_OPS
};
10 changes: 0 additions & 10 deletions gpx.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ class GpxFormat : public Format
return FF_CAP_RW_ALL;
}

QString get_encode() const override
{
return CET_CHARSET_UTF8;
}

int get_fixed_encode() const override
{
return 0;
}

void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override;
Expand Down
1 change: 0 additions & 1 deletion gtm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,5 @@ ff_vecs_t gtm_vecs = {
gtm_write,
nullptr,
&gtm_args,
CET_CHARSET_ASCII, 0, /* CET-REVIEW */
NULL_POS_OPS
};
12 changes: 1 addition & 11 deletions gtrnctr.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <QVector> // for QVector
#include <QXmlStreamAttributes> // for QXmlStreamAttributes

#include "defs.h" // for arglist_t, ff_cap, route_head, Waypoint, computed_trkdata, ARG_NOMINMAX, ff_cap_read, ARGTYPE_BOOL, ARGTYPE_STRING, CET_CHARSET_ASCII, ff_cap_none, ff_cap_write, ff_type, ff_type_file
#include "defs.h" // for arglist_t, ff_cap, route_head, Waypoint, computed_trkdata, ARG_NOMINMAX, ff_cap_read, ARGTYPE_BOOL, ARGTYPE_STRING, ff_cap_none, ff_cap_write, ff_type, ff_type_file
#include "format.h" // for Format
#include "gbfile.h" // for gbfile
#include "src/core/datetime.h" // for DateTime
Expand Down Expand Up @@ -60,16 +60,6 @@ class GtrnctrFormat : public Format
};
}

QString get_encode() const override
{
return CET_CHARSET_ASCII;
}

int get_fixed_encode() const override
{
return 0;
}

void rd_init(const QString& fname) override;
void read() override;
void rd_deinit() override;
Expand Down
3 changes: 1 addition & 2 deletions holux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,5 @@ ff_vecs_t holux_vecs = {
data_write,
nullptr,
nullptr,
CET_CHARSET_ASCII, 0 /* CET-REVIEW */
, NULL_POS_OPS
NULL_POS_OPS
};
Loading

0 comments on commit aac3c51

Please sign in to comment.