Skip to content

Commit

Permalink
Item13442: Tweaks made on foswiki.org
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Jun 2, 2015
1 parent 6b98521 commit 30521c4
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/Foswiki/Contrib/CharsetConverterContrib.pm
Expand Up @@ -28,7 +28,7 @@ our $session;

sub report {
return if $options->{-q};
print join( ' ', @_ ) . "\n";
print STDERR join( ' ', @_ ) . "\n";
}

sub warning {
Expand All @@ -50,6 +50,21 @@ sub detect_encoding {
return;
}

# Add any hand-tuned fixups here to adjust for strange
# encodings detected in your local data. Passed 2 arguments
# - The detected encoding, and the data.
#
sub _fixupDetect {

#my $enc, $data = @_;

# return 'iso-8859-1' if ( $_[0] =~ /^BIG/ );
# return 'utf-8' if ( $_[0] =~ /^EUC/ );
# return 'windows-1252' if ( $_[0] eq 'Shift-JIS' );
return $_[0];

}

# Convert a byte string encoded in the {Site}{CharSet} to a byte
# string encoded in utf8
# Return 1 if a conversion happened, 0 otherwise
Expand All @@ -63,7 +78,11 @@ sub _convert_string {
my $de = Encode::Detect::Detector::detect($old);
if ( $de && $de ne $Foswiki::cfg{Site}{CharSet} ) {
warning("$de encoding detected in $where");
$e = $de;

# Chance to tweak the encooding.
$e = _fixupDetect( $de, $old );
warning("Encoding $de overridden to $e by _fixupDetect()")
unless ( $e eq $de );
}
}

Expand Down Expand Up @@ -174,6 +193,7 @@ sub _rename_collection {
sub _convert_topic {
my ( $web, $topic ) = @_;
my $converted = 0;
print STDERR "START conversion of $web/$topic\n";

# Convert .txt,v
my $handler =
Expand Down

0 comments on commit 30521c4

Please sign in to comment.