php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39261 strftime chops characters with utf-8
Submitted: 2006-10-26 02:16 UTC Modified: 2006-10-26 21:21 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: mehmetyucel at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.1.6 OS: MS Windows 2003 ES/Fedora Core 5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mehmetyucel at gmail dot com
New email:
PHP Version: OS:

 

 [2006-10-26 02:16 UTC] mehmetyucel at gmail dot com
Description:
------------
If the localization that is set by setlocale has non ISO-8859-1 characters strftime destroys these.
Reproducable on both Fedora Core 5 and Windows 2003 Enterprise Server tested for 2 languages (Spanish / Turkish)

Reproduce code:
---------------
header('Content-Type: text/html; charset=utf-8');

setlocale(LC_TIME,"spanish");
echo strftime("%d %B %Y %A",strtotime("2006-10-28"))."<br>";
setlocale(LC_TIME,"turkish");
echo strftime("%d %B %Y %A",strtotime("2006-10-26"))."<br>";
echo strftime("%d %B %Y %A",strtotime("2006-10-25"))."<br>";


Expected result:
----------------
28 octubre 2006 s?bado
26 Ekim 2006 Per&#351;embe
25 Ekim 2006 ?ar&#351;amba

Actual result:
--------------
28 octubre 2006 s&#6305;do
26 Ekim 2006 Per?r>25 Ekim 2006 &#481;r?r>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-26 09:17 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-10-26 11:42 UTC] mehmetyucel at gmail dot com
5.2 snapshot solved the issue on linux, but problem still exists for windows.

Somehow setlocale sets output encoding of strftime. Following works as a temporary solution for window env.

iconv("ISO-8859-9","UTF-8",strftime("%d %B %Y %A",strtotime("2006-10-26")));
 [2006-10-26 21:21 UTC] derick@php.net
strftime() behaves depending in the OS. As far as I can see it's not even a bug and it's just how Windows handles locales and selects utf8 when it feels like.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 07:01:32 2024 UTC