freebsd-ports/multimedia/w_scan2/files/patch-src_char-coding.c
Rene Ladan 35abb7189a multimedia/w_scan2: add working fork of expiring multimedia/w_scan
w_scan2 is a small channel scan tool which generates ATSC, DVB-C,
DVB-S/S2 and DVB-T/T2 channels.conf files.

It's based on the old "scan" tool from linuxtv-dvb-apps-1.1.0. The
differences are:
* no initial tuning data needed, because scanning without this data
  is exactly what a scan tool like this should do.
* it detects automatically which DVB/ATSC card to use.
* much more output formats, interfacing to other dtv software.

w_scan2 is a fork of the original w_scan from
https://www.gen2vdr.de/wirbel/w_scan/index2.html

Main changes from w_scan to w_scan2:
* keep duplicate transponders by default because a stronger transponder
  with the same ID might have a higher frequency and be discarded simply
  because it's scanned later. Also don't replace the current transponder
  with an advertised one by default. The latter may have a lower signal
  strength. More details here:
  https://stefantalpalaru.wordpress.com/2016/02/04/scan-all-the-things/
  The old behaviour can be enabled with -d (--delete-duplicate-transponders).
* re-enable VHF band III in Europe

WWW: https://github.com/stefantalpalaru/w_scan2

Suggested by:	hselasky
2020-08-22 16:08:11 +00:00

35 lines
1.2 KiB
C

--- src/char-coding.c.orig 2020-08-22 13:49:25 UTC
+++ src/char-coding.c
@@ -340,14 +340,31 @@ void char_coding(char **inbuf, size_t * inbytesleft, c
// Fallback method: copy all printable chars from *inbuf to *outbuf.
size_t i;
size_t pos = 0;
-
+#ifdef __FreeBSD__
+ int to_utf = user_charset_id < iconv_codes_count() &&
+ !strncmp(iconv_codes[user_charset_id], "UTF", sizeof "UTF" - 1);
+#endif
for (i = 0; i < nsrc; i++) {
switch ((uint8_t) * (psrc + i)) {
//case 0x20 ... 0x7E:
//case 0xA0 ... 0xFF:
// printable chars ISO-6937-2
// Figure A.1: Character code table 00 - Latin alphabet
+#ifdef __FreeBSD__
+ case 0x80 ... 0xFF:
+ // the iconv used on FreeBSD doesn't know about the
+ // default DVB charset ISO-6397-2 so we'll end up here
+ // for 8-bit chars in channel names that are (usually
+ // wrongly) specified as the default charset - and if
+ // we are converting to UTF those will create invalid
+ // encodings.
+ if (to_utf)
+ continue;
+ // FALLTHRU
+ case 0x01 ... 0x7F:
+#else
case 0x01 ... 0xFF: // 20121202: don't touch anything; leave it as it is.
+#endif
*(pdest + pos++) = *(psrc + i);
default:;
}