From: tsteven4 Date: Tue, 16 Sep 2014 00:12:17 +0000 (+0000) Subject: use utf8, our preferred encoding, in gbfputs. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~11^2~75 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f60237a1b3a442c5e6c86e2f8311c77a8dc603bd;p=gpsbabel.git use utf8, our preferred encoding, in gbfputs. --- diff --git a/gpsbabel/gbfile.cc b/gpsbabel/gbfile.cc index a5ae1f120..7a05780c7 100644 --- a/gpsbabel/gbfile.cc +++ b/gpsbabel/gbfile.cc @@ -787,13 +787,8 @@ gbfputs(const char* s, gbfile* file) int gbfputs(const QString& s, gbfile* file) { - // Why is this Latin1() and not toUtf8()? Becuase our string data is - // already utf8 in most of the "C" places and calling toUtf8() here would - // double encode them. - const char* qs = xstrdup(s.toLatin1().data()); - unsigned int l = strlen(qs); - int rv = gbfwrite(qs, 1, l, file); - xfree(qs); + QByteArray qs = s.toUtf8(); + int rv = gbfwrite(qs.constData(), 1, qs.size(), file); return rv; } diff --git a/gpsbabel/reference/unicsv_encoding.csv b/gpsbabel/reference/unicsv_encoding.csv new file mode 100644 index 000000000..708d01254 --- /dev/null +++ b/gpsbabel/reference/unicsv_encoding.csv @@ -0,0 +1,2 @@ +No,Latitude,Longitude,Name,Description,Notes +1,40.000000,-105.000000,"α","β","ξ" diff --git a/gpsbabel/reference/unicsv_encoding.gpx b/gpsbabel/reference/unicsv_encoding.gpx new file mode 100644 index 000000000..fa9be3862 --- /dev/null +++ b/gpsbabel/reference/unicsv_encoding.gpx @@ -0,0 +1,10 @@ + + + + + + α + β + ξ + + diff --git a/gpsbabel/testo.d/unicsv.test b/gpsbabel/testo.d/unicsv.test index f84aae274..fe131328c 100644 --- a/gpsbabel/testo.d/unicsv.test +++ b/gpsbabel/testo.d/unicsv.test @@ -18,3 +18,7 @@ compare ${TMPDIR}/gcunicsv-1.csv ${TMPDIR}/gcunicsv-2.csv # check header detection features gpsbabel -i unicsv,utc=0 -f ${REFERENCE}/headerdetection.unicsv -x transform,trk=wpt -o gpx,garminextensions -F ${TMPDIR}/headerdetection~unicsv.gpx compare ${TMPDIR}/headerdetection~unicsv.gpx ${REFERENCE}/extensiondata~unicsv.gpx + +# check default encoding, i.e. utf-8 in and out. +gpsbabel -i gpx -f ${REFERENCE}/unicsv_encoding.gpx -o unicsv -F ${TMPDIR}/unicsv_encoding.csv +compare ${TMPDIR}/unicsv_encoding.csv ${REFERENCE}/unicsv_encoding.csv