Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows server, php-generated utf-8 days with accents not displayed correctly #973

Closed
torvista opened this issue Jun 5, 2016 · 10 comments
Closed
Assignees

Comments

@torvista
Copy link
Member

torvista commented Jun 5, 2016

This has always been a problem on the Windows Xampp servers I use and is no different on Windows 10/php 7 for locale Spanish_Spain.1252.

clipboard02
clipboard01

I could not find any other way to solve this apart from treating windows differently as this is not a problem on my Nix server.
So for the two function zen_date_long,
I have had this in place for a long time:
return ( stristr(PHP_OS,"win") ? utf8_encode(strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year))) : strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year)) );

Maybe someone could comment if IIS has the same issue...

Note I have a working spanish language pack in progress for 1.6 if anyone wants it for testing.

@drbyte
Copy link
Member

drbyte commented Jun 5, 2016

Wondering if ...

in locale.php does changing LC_TIME to LC_ALL help resolve it?

setlocale(LC_TIME, $locales);
vs
setlocale(LC_ALL, $locales);

What about adding this to your configure.php file (just to force your PHP into all-utf8, to hopefully make it auto-encode these locale-generated strings as utf8 by default)?

ini_set('default_charset', "UTF-8");

@drbyte
Copy link
Member

drbyte commented Jun 5, 2016

(and, yes, I'd welcome a demo copy of your spanish language pack ... care to post a download URL?)

@torvista
Copy link
Member Author

torvista commented Jun 6, 2016

@drbyte
Copy link
Member

drbyte commented Jun 6, 2016

Sigh. It's incredibly unfortunate that Windows remains so inferior in its support of things as simple as locales in this modern era.

It's frustrating to have to code exceptions specifically for Windows.

Or is this unique to Xampp?

@drbyte
Copy link
Member

drbyte commented Jun 6, 2016

I'd recommend the following slight alteration from your posted code from this:

return ( stristr(PHP_OS,"win") ? utf8_encode(strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year))) : strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year)) );

to this:

  $retVal = strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year));
  if (stristr(PHP_OS, 'win')) return utf8_encode($retVal);
  return $retVal;

BUT ALSO:
Do you have a nix server to test another variation on? What if we just always return the utf8_encoded value, even if not on Windows? Is that going to make things worse? (I don't have a spanish server to test this on)

@torvista
Copy link
Member Author

torvista commented Jun 6, 2016

Or is this unique to Xampp?

Can't say, I did the post to encourage more results from real servers. Xampp is not a real-world reference but it's all I've got to go on. I have seen the question about corrupted days crop up now and again so it evidently is not a common issue/windows is not a common server. But, people think it is to do with their files/database.

Do you have a nix server to test another variation on?

No, all my sites are on the same hosting.

What if we just always return the utf8_encoded value, even if not on Windows? Is that going to make things worse?

Yes, since Nix returns a utf-8 code ok by default, it gets corrupted by using utf8_encode on top of it.
So it has to be windows-specific in my testing.

(I don't have a spanish server to test this on)

Not sure what you mean by a "spanish server"? My sites are on Terranetworks UK.

@drbyte
Copy link
Member

drbyte commented Jun 6, 2016

Not sure what you mean by a "spanish server"?

Oops ... meant to say: I don't have a spanish language pack to test a ZC site installed on a server in order to test any spanish locale concerns

@torvista
Copy link
Member Author

torvista commented Jun 6, 2016

(and, yes, I'd welcome a demo copy of your spanish language pack ... care to post a download URL?)

Ok, this is a first pass.
Admin: I have examined all the files, so all constants should be in place. Most translations are done apart from large chunks of new ones I didn't feel like doing now.
Catalog: I have equalized the fileset, new files will not be translated, but all constants should be in place.
It works anyway, should be no white screens of death nor encoding issues!!
https://dl.dropboxusercontent.com/u/57111073/zen-cart-16_spanish.7z

@torvista
Copy link
Member Author

torvista commented Jun 7, 2016

@torvista
Copy link
Member Author

Just to confuse things further, "interestingly" (not) is that if the locale is set to es-ES (on windows), this outputs the corrupted accent as previously seen:
$retVal = strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year));

but this outputs a correct accent:

$retVal = MessageFormatter::formatMessage(
        'es-ES',
        "{0, date, full}",
        array(mktime($hour, $minute, $second, $month, $day, $year))
    );

This issue is just not worth the effort, but at least the background mess is a bit more documented now.

drbyte added a commit to drbyte/zencart that referenced this issue Jun 28, 2016
@drbyte drbyte self-assigned this Jun 28, 2016
zcwilt pushed a commit that referenced this issue Jul 5, 2016
@zcwilt zcwilt removed the in progress label Jul 5, 2016
drbyte added a commit that referenced this issue Dec 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants