From: robertl Date: Sun, 16 Jan 2005 23:22:19 +0000 (+0000) Subject: Bust UTF-8 encoded waypoint names and comments down to ASCII for Mapsend. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~11^2~3827 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3c5b58921d3f2c0acf24084af112574b2ef0fc67;p=gpsbabel.git Bust UTF-8 encoded waypoint names and comments down to ASCII for Mapsend. --- diff --git a/gpsbabel/mapsend.c b/gpsbabel/mapsend.c index c7e24feba..1bf106af7 100644 --- a/gpsbabel/mapsend.c +++ b/gpsbabel/mapsend.c @@ -318,19 +318,41 @@ mapsend_waypt_pr(const waypoint *waypointp) const char *sn = global_opts.synthesize_shortnames ? mkshort(mkshort_handle, waypointp->description) : waypointp->shortname; + char *tmp; - c = sn ? strlen(sn) : 0; + /* + * The format spec doesn't call out the character set of waypoint + * name and description. Empirically, we can see that it's 8859-1, + * but if we create mapsend files containing those, Mapsend becomes + * grumpy uploading the resulting waypoints and being unable to deal + * with the resulting comm errors. + * + * Ironically, our own Magellan serial module strips the "naughty" + * characters, keeping it more in definition with their own serial + * spec. :-) + * + * So we just decompose the utf8 strings to ascii before stuffing + * them into the Mapsend file. + */ + + tmp = str_utf8_to_ascii(sn); + c = tmp ? strlen(tmp) : 0; fwrite(&c, 1, 1, mapsend_file_out); - fwrite(sn, c, 1, mapsend_file_out); + fwrite(tmp, c, 1, mapsend_file_out); + if (tmp) + xfree(tmp); - if (waypointp->description) - c = strlen(waypointp->description); + tmp = str_utf8_to_ascii(waypointp->description); + if (tmp) + c = strlen(tmp); else c = 0; if (c > 30) c = 30; fwrite(&c, 1, 1, mapsend_file_out); - fwrite(waypointp->description, c, 1, mapsend_file_out); + fwrite(tmp, c, 1, mapsend_file_out); + if (tmp) + xfree(tmp); /* #, icon, status */ n = ++cnt;