Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

tv_grab_fi utf-8 output

By: a guest on Nov 29th, 2010  |  syntax: Diff  |  size: 1.63 KB  |  views: 39  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. --- tv_grab_fi_orig     2010-11-29 21:06:28.730006915 +0200
  2. +++ tv_grab_fi  2010-11-29 21:45:53.490007056 +0200
  3. @@ -235,7 +235,7 @@
  4.      die "cannot write to $opt_output: $!" if not defined $fh;
  5.      $w_args{OUTPUT} = $fh;
  6.  }
  7. -$w_args{encoding} = 'ISO-8859-1';
  8. +$w_args{encoding} = 'UTF-8';
  9.  my $writer = new XMLTV::Writer(%w_args);
  10.  $writer->start($HEAD);
  11.  
  12. @@ -335,27 +335,6 @@
  13.      }
  14.  }
  15.  
  16. -my $warned_bad_chars;
  17. -sub tidy( $ ) {
  18. -  my($string) = @_;
  19. -  $string = decode_utf8($string);
  20. -
  21. -  # Make contents ISO-8859-1 compatible
  22. -  # TAB                                  => space
  23. -  # U+2013 (EN DASH)                     => -
  24. -  # U+2019 (RIGHT SINGLE QUOTATION MARK) => '
  25. -  # U+201D (RIGHT DOUBLE QUOTATION MARK) => "
  26. -  $string =~ tr/\t\N{U+2013}\N{U+2019}\N{U+201D}/ \-\'\"/;
  27. -
  28. -  # Warn about incomplete replacement
  29. -  if ($string =~ s/([^\N{U+0000}-\N{U+00FF}])//g) {
  30. -    warn "removing bad character: 0x" . sprintf("%04x", ord($1))
  31. -      unless ($warned_bad_chars++ or $opt_quiet);
  32. -  }
  33. -
  34. -  return $string;
  35. -}
  36. -
  37.  ####
  38.  # process_table: fetch a URL and process it
  39.  #
  40. @@ -371,7 +350,7 @@
  41.      my $today = UnixDate($date, '%Y%m%d');
  42.      my $url = "$SITE/channel/list/$ch_their_id/$today";
  43.      t "getting URL: $url";
  44. -    my $tree = get_nice_tree $url, \&tidy;
  45. +    my $tree = get_nice_tree $url;
  46.      local $SIG{__WARN__} = sub {
  47.         warn "$url: $_[0]";
  48.      };
  49. @@ -553,7 +532,7 @@
  50.  
  51.      my $url="$SITE/channel";
  52.      t "getting URL: $url";
  53. -    my $tree = get_nice_tree($url, \&decode_utf8);
  54. +    my $tree = get_nice_tree($url);
  55.  
  56.      # FIXME commonize this
  57.      local $SIG{__WARN__} = sub {
clone this paste RAW Paste Data