Bug #65371 [Asn->Fbk]: strftime() returns insufficient string

From: Date: Fri, 23 Jan 2015 12:41:34 +0000
Subject: Bug #65371 [Asn->Fbk]: strftime() returns insufficient string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190160@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65371&edit=1

 ID:                 65371
 Updated by:         ab@php.net
 Reported by:        kenji dot uui at gmail dot com
 Summary:            strftime() returns insufficient string
-Status:             Assigned
+Status:             Feedback
 Type:               Bug
 Package:            Date/time related
 Operating System:   Windows
 PHP Version:        5.5.1
 Assigned To:        ab
 Block user comment: N
 Private report:     N

 New Comment:

OK, after some testing i can now reproduce this behavior even with english system locale. For that,
just use

setlocale(LC_ALL, "japanese");

I've also tested a bit more and it looks that at least codepages 932, 936, 950 affect strftime
to be working a different way, at least with vc11. I made a mini build with vc12, so you can test it
http://windows.php.net/downloads/snaps/ostc/65371/
(you'll need the 64 bit crt redistributable http://www.microsoft.com/en-US/download/details.aspx?id=40784).

But actually I'm more like don't believe it's about CRT but the strftime and locale
itself. It seems to build a special case along with the code pages listed above (and maybe more).
Many other locales which set a single byte code page show correct behaviors when passing utf8
strings to strftime. Yet another try could be with using _strftime_l, however it's the same as
strftime just needs an explicitly passed locale, so more like a no-go.

Thanks.


Previous Comments:
------------------------------------------------------------------------
[2015-01-22 22:31:46] kenji dot uui at gmail dot com

I hear this bug is because of VC11 strftime.

Workround is below:

function strftime_win($str)
{
  $str = mb_convert_encoding($str, 'CP932', 'UTF-8');
  return mb_convert_encoding(strftime($str), 'UTF-8', 'CP932');
}

------------------------------------------------------------------------
[2015-01-22 21:36:48] kenji dot uui at gmail dot com

I tested on PHP 5.5.21. Not fixed yet.

Results:
----------------
あ
ぁE
e38182
e3818145

------------------------------------------------------------------------
[2015-01-22 12:01:18] ab@php.net

Could you please revisit this? There was a lot of locale fixes recently, you could check 5.5.21 or
just some recent 5.5 on windows.php.net .

Thanks.

------------------------------------------------------------------------
[2014-01-11 13:39:27] kenji dot uui at gmail dot com

I found Windows system locale affects the result.
I changed it to English(US), then I got expected result.

The problem occurs in Japanese locale.

------------------------------------------------------------------------
[2014-01-09 12:36:10] ab@php.net

Ok, sadly I can't reproduce it neither with 5.4 nor with 5.5, got your expected result with CLI
and built-in server. There has to be something in your env causing this. Maybe you could try on some
other machine, with some other locale, etc? Also note that under apache the locale is not thread
safe (as apache under windows is threads based), there it might be possible because of it.

Thanks.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=65371


--
Edit this bug report at https://bugs.php.net/bug.php?id=65371&edit=1


Thread (10 messages)

« previous php.bugs (#190160) next »