1 This v2 patch is a different approach after Joey's comments and some though.
5 1. Proper local time, if the locale configuration option is used,
6 2. Support for UTF-8 (or ISO-8859-X) filenames in SVN. Before this
7 patch, commiting (or even rcs_updating) on repositories with UTF-8
8 filenames was impossible.
10 The svn backend sets `LC_CTYPE` to the following, in order of preference:
12 * The current locale, if it contains utf8/UTF-8,
13 * The current locale with the string ".UTF-8" appended to it,
14 * `en_US.UTF-8`/`en_GB.UTF-8` -- a bit hacky, but they're _very_ common and
15 they can help avoiding a call to `locale -a`, which may not be available
16 in the current system,
17 * The first UTF-8 locale it encounters from `locale -a`. Note that `LC_CTYPE`
18 is the same for every UTF-8 locale, so it doesn't matter which one will be used.
23 Index: IkiWiki/Rcs/svn.pm
24 ===================================================================
25 --- IkiWiki/Rcs/svn.pm (revision 967)
26 +++ IkiWiki/Rcs/svn.pm (working copy)
31 +use POSIX qw(setlocale LC_CTYPE);
35 my $svn_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/;
37 +sub find_lc_ctype() {
38 + my $current = setlocale(LC_CTYPE);
40 + # Respect current locale if it's a UTF-8 one
41 + return $current if $current =~ m/UTF-?8$/i;
43 + # Make some obvious attempts to avoid calling `locale -a`
44 + foreach my $locale ("$current.UTF-8", "en_US.UTF-8", "en_GB.UTF-8") {
45 + return $locale if setlocale(LC_CTYPE, $locale);
48 + # Try to get all available locales and pick the first UTF-8 one if found
49 + if (my @locale = grep(/UTF-?8$/i, `locale -a`)) {
51 + return $locale[0] if setlocale(LC_CTYPE, $locale[0]);
54 + # fallback to the current locale
58 +$ENV{LC_CTYPE} = $ENV{LC_CTYPE} || find_lc_ctype();
60 sub svn_info ($$) { #{{{
64 ===================================================================
65 --- IkiWiki.pm (revision 967)
66 +++ IkiWiki.pm (working copy)
69 plugin => [qw{mdwn inline htmlscrubber}],
74 sub checkconfig () { #{{{
75 + # locale stuff; avoid LC_ALL since it overrides everything
76 + if (defined $ENV{LC_ALL}) {
77 + $ENV{LANG} = $ENV{LC_ALL};
78 + delete $ENV{LC_ALL};
80 + if (defined $config{locale}) {
82 + $ENV{LANG} = $config{locale}
83 + if POSIX::setlocale(&POSIX::LANG, $config{locale});
86 if ($config{w3mmode}) {
87 eval q{use Cwd q{abs_path}};
88 $config{srcdir}=possibly_foolish_untaint(abs_path($config{srcdir}));
89 Index: doc/ikiwiki.setup
90 ===================================================================
91 --- doc/ikiwiki.setup (revision 967)
92 +++ doc/ikiwiki.setup (working copy)
94 #exclude => qr/\*.wav/,
95 # Time format (for strftime)
97 + # Locale to be used, useful for language customization of last-modified
98 + # time. WARNING: Must be a UTF-8 locale!
99 + #locale => 'en_US.UTF-8',
101 # To add plugins, list them here.
102 #add_plugins => [qw{meta tag pagecount brokenlinks search smiley