Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Characters in pages are garbled (get "mojibake") with Perl 5.22.0 or later #134

Merged
merged 3 commits into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/Sympa/Language.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use strict;
use warnings;
use base qw(Class::Singleton);

use Encode qw();
use Locale::Messages;
use POSIX qw();

Expand Down Expand Up @@ -688,6 +689,7 @@ sub gettext_strftime {
POSIX::setlocale(POSIX::LC_TIME(), $self->{locale_time});
}
my $ret = POSIX::strftime($format, @args);
Encode::_utf8_off($ret);

POSIX::setlocale(POSIX::LC_TIME(), $orig_locale);
return $ret;
Expand Down
10 changes: 10 additions & 0 deletions t/Language.t
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ my %tests = (
## Emulated strftime()
gettext_strftime =>
[['%a, %d %b %Y' => "\xC4\x8Ct 01. Led 1970", 'emulated strftime'],],

## Failed if utf8 flag set
gettext_strftime_noutf8 => [['%a, %d %b %Y'],],
);

plan tests => scalar map {@$_} values %tests;
Expand Down Expand Up @@ -299,3 +302,10 @@ foreach my $test (@{$tests{gettext_strftime}}) {
"gettext_strftime($test->[0])" . ($test->[2] ? ": $test->[2]" : ''));
}

# PR #134
$language->set_lang('zh-TW');
foreach my $test (@{$tests{gettext_strftime_noutf8}}) {
ok(!Encode::is_utf8($language->gettext_strftime($test->[0], gmtime 0)),
"!is_utf8 gettext_strftime($test->[0])");
}