Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cc042e07

Von Sven Schöling vor mehr als 14 Jahren hinzugefügt

  • ID cc042e07ef78786b758b22cee75509815e59ba5b
  • Vorgänger 5367525b
  • Nachfolger ad7353df

UTF8-Flags setzen/beachten

Conflicts:

SL/ReportGenerator.pm

Unterschiede anzeigen:

SL/Locale.pm
36 36

  
37 37
package Locale;
38 38

  
39
use Text::Iconv;
39
use Encode;
40 40
use List::Util qw(first);
41
use List::MoreUtils qw(any);
41 42

  
42 43
use SL::LXDebug;
43 44
use SL::Common;
45
use SL::Iconv;
44 46
use SL::Inifile;
45 47

  
46 48
use strict;
......
88 90
  }
89 91

  
90 92
  my $db_charset            = $main::dbcharset || Common::DEFAULT_CHARSET;
93
  $self->{is_utf8}          = (any { lc($::dbcharset || '') eq $_ } qw(utf8 utf-8 unicode)) ? 1 : 0;
91 94

  
92
  $self->{iconv}            = Text::Iconv->new($self->{charset}, $db_charset);
93
  $self->{iconv_reverse}    = Text::Iconv->new($db_charset,      $self->{charset});
94
  $self->{iconv_english}    = Text::Iconv->new('ASCII',          $db_charset);
95
  $self->{iconv_iso8859}    = Text::Iconv->new('ISO-8859-15',    $db_charset);
96
  $self->{iconv_to_iso8859} = Text::Iconv->new($db_charset,      'ISO-8859-15');
95
  if ($self->{is_utf8}) {
96
    binmode STDOUT, ":utf8";
97
    binmode STDERR, ":utf8";
98
  }
99

  
100
  $self->{iconv}            = SL::Iconv->new($self->{charset}, $db_charset);
101
  $self->{iconv_reverse}    = SL::Iconv->new($db_charset,      $self->{charset});
102
  $self->{iconv_english}    = SL::Iconv->new('ASCII',          $db_charset);
103
  $self->{iconv_iso8859}    = SL::Iconv->new('ISO-8859-15',    $db_charset);
104
  $self->{iconv_to_iso8859} = SL::Iconv->new($db_charset,      'ISO-8859-15');
97 105

  
98 106
  $self->_read_special_chars_file($country);
99 107

  
......
105 113
    (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec));
106 114
}
107 115

  
116
sub is_utf8 {
117
  my $self   = shift;
118
  my $handle = shift;
119
  return $self->{is_utf8} && (!$handle || $handle->is_utf8);
120
}
121

  
108 122
sub _handle_markup {
109 123
  my $self    = shift;
110 124
  my $str     = shift;
......
406 420
  return $self->quote_special_chars($dst_format, $self->quote_special_chars("${src_format}-reverse", shift));
407 421
}
408 422

  
423
sub with_raw_io {
424
  my $self = shift;
425
  my $fh   = shift;
426
  my $code = shift;
427

  
428
  binmode $fh, ":raw";
429
  $code->();
430
  binmode $fh, ":utf8" if $self->is_utf8;
431
}
432

  
409 433
1;

Auch abrufbar als: Unified diff