PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Internationalization » I18Nv2 » Bug #4816

converting charset of strftime result

Details

Submitted2005-07-13 10:03 UTC
Frommunzeitig at sigmatec dot cz
StatusSuspended
PackageI18Nv2
PHP Version4.3.11
OSWindows
Roadmaps(Not assigned)

Comments

[2005-07-13 10:03 UTC] munzeitig at sigmatec dot cz

Description:
------------
There is problem with charset of day and month names returned by strftime() function used internally I18Nv2.

E.g. in our project, we use UTF-8 everywhere = as internal, output and input charset, however the result of strftime() function is not in UTF-8 and needs to be reformated.

It is not possible to use autoConv(), because that would break others part of code which are already UTF-8 (it is not possibly to apply in general).

Therefore I suggest there should be some additional functionality added, which will check and ensure that the results of strftime() returned by OS are in desired charset compatible with rest of the code.

Reproduce code:
---------------
// All is in UTF-8 by default. (internal & output)

// This works wrong.
echo $locale->formatDate(null, I18Nv2_DATETIME_LONG);
// Returns 13 襲venec 2005 (wrong).

// This works fine.
echo iconv(null, 'UTF-8', $locale->formatDate(null, I18Nv2_DATETIME_LONG));
// Returns 13 èervenec 2005 (correct).

[2005-07-13 10:27 UTC] munzeitig at sigmatec dot cz

Just noticed this problem was somehow discussed in bug 4222.

I guess that using the iconv(null, 'UTF-8', $string) or more general iconv(null, $reqestedEncoding, $string) in definitions in Locale class could solve this problem -- at least it does for me.

So something like using:
$this->abbrDays = array(
iconv(null, $reqestedEncoding, strftime('%a', $sun)),
iconv(null, $reqestedEncoding, strftime('%a', $mon)),
...
instead of:
$this->abbrDays = array(
strftime('%a', $sun),
strftime('%a', $mon),
...

This is just for demostration, there could be more wise solution of course. E.g. converting all the results in the definition arrays in foreach or so in case there the $requestedEncoding is set.

[2005-07-21 12:17 UTC] munzeitig at sigmatec dot cz

Nope it doesn't. I have tried almost everything. Except using iconv on the results of strftime('%a', $sun) as I wrote above nothing helped so far.

[2005-07-21 15:51 UTC] munzeitig at sigmatec dot cz

No, in fact Windows is the testing site only. Anyway it is quite embarassing.

I've noticed that the other bug is marked as Won't fix. However I've also suggested a specific solution to consider. ;-)