Stas Bekman wrote:
Ruslan U. Zakirov wrote:

Stas Bekman wrote:

Ruslan U. Zakirov wrote:

Apache-2 form CVS as mp2.
Some locale/UTF issues?
I think it's not critical issue and I could force make install.

Verbose make test output:
t/apache/util....1..4
# Running under perl version 5.008003 for linux
# Current time local: Tue Mar 16 18:33:54 2004
# Current time GMT:   Tue Mar 16 15:33:54 2004
# Using Test.pm version 1.24
# testing : Apache::Util::ht_time($pool)
# expected: (?-xism:^\w\w\w, \d\d \w\w\w \d\d\d\d \d\d:\d\d:\d\d)
# received: ÐÑÐ, 16 ÐÐÑ 2004 15:33:57 GMT
not ok 1



[snip]

Hello, Stas.


Ouch, I thought that \w will match any letter, but I guess it won't w/o loading locale. Does the problem go away if you apply this patch?


Nop.
I've got absolutely same results. I have ru_RU.CP1251 locale. And output from Apache::Util::ht_time conform to this. I see right date in console.


NAME
locale - Perl pragma to use and avoid POSIX locales for built-in opera-
tions


This pragma tells the compiler to enable (or disable) the use of POSIX
locales for built-in operations (LC_CTYPE for regular expressions, and
LC_COLLATE for string comparison). Each "use locale" or "no locale"
affects statements to the end of the enclosing BLOCK.


So, does your LC_CTYPE matches LC_TIME? If it doesn't, that will explain the problem.
Does.
[EMAIL PROTECTED] cubic]$ echo $LC_CTYPE

[EMAIL PROTECTED] cubic]$ echo $LC_TIME

[EMAIL PROTECTED] cubic]$ echo $LANG
ru_RU.CP1251
[EMAIL PROTECTED] cubic]$ locale
LANG=ru_RU.CP1251
LC_CTYPE="ru_RU.CP1251"
LC_NUMERIC="ru_RU.CP1251"
LC_TIME="ru_RU.CP1251"
LC_COLLATE="ru_RU.CP1251"
LC_MONETARY="ru_RU.CP1251"
LC_MESSAGES="ru_RU.CP1251"
LC_PAPER="ru_RU.CP1251"
LC_NAME="ru_RU.CP1251"
LC_ADDRESS="ru_RU.CP1251"
LC_TELEPHONE="ru_RU.CP1251"
LC_MEASUREMENT="ru_RU.CP1251"
LC_IDENTIFICATION="ru_RU.CP1251"
LC_ALL=


I'v checked $fmtdate with Encode::is_utf8, it's not utf8 internal format in both cases. I never used a lot 'use locale' so don't know how exactly perl handle regexps in this case.

I have success with next tricky code:
$fmtdate = Apache::Util::ht_time($r->pool);
$fmtdate = Encode::decode('cp1251', $fmtdate);


What's the transparent way to accomplish that? 'use locale' should have done that I believe. See the perllocale manpage.
This experiment say that 'locale' is working fine:
perl -Mlocale -e 'print +(sort grep /\w/, map { chr } 0..255), "\n";'
Â_0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZÐÐÐÐÐÐÐÐÐÐÑÐÒÒÑÐÐÐÑÐÑÐÐÐÐÐÑÐÐÐÑÐÑÐÐÐÑÐÐÐÐÐÑÐÐÐÐÐÑÐÐÐÐÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐÑÐ
perl -e 'print +(sort grep /\w/, map { chr } 0..255), "\n";'
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz


I found solution. I've placed 'use locale' in package scope instead of sub scope and test goes fine. Perl "bug/feature"?


Best regards. Ruslan.




--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to