Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Problem with Event calendar and localizated dates


Go to End


16 Posts   4843 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 September 2009 at 11:35am

Run an update and let me know if that fixes the problem for you.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 September 2009 at 11:39am

Whoops. Missed the last two posts.

Banal, I don't think we need to worry about users who already use UTF-8 because Silverstripe throws an HTTP header for the UTF-8 charset on all responses, right?

Avatar
bummzack

Community Member, 904 Posts

8 September 2009 at 6:56pm

Edited: 08/09/2009 6:57pm

Hey UncleCheese
Sadly not, if you run an UTF-8 encoded string through utf8_encode, you'll end up with garbled umlauts. And that's exactly what will happen if you use a UTF-8 locale and run the strftime output through utf8_encode. I suggest you revert back to the previous version and tell the users to use the setlocale fix, where the user has to switch to an UTF-8 locale.

Avatar
joninjas

Community Member, 32 Posts

6 November 2009 at 11:10pm

Hi all,

I had the same problem in german, that März was written with ? instead of ä.

I activated the following line in event_calendar/code/CalendarUtil.php (line: 85):

// Need to figure out how we're handling non- UTF-8 users.
return utf8_encode(strftime($char, $ts));
//return strftime($char,$ts);

With the return strftime($char,$ts); it didn't bring back the right value, it was ISO-8859-1 encoded and the website showed, to whatever encoding changed in the browser, mixed content with ä and ?.

Now I can run the whole site under UTF-8. Cool

Cheers
Jonas

Avatar
Beutlin

Community Member, 2 Posts

27 February 2010 at 2:15pm

Edited: 27/02/2010 2:17pm

Hello,

is guess, this is still an unsolved problem. On my PC (de_DE.utf8) only

return strftime($char,$ts);
works. On my server (de_DE) only
utf8_encode(strftime($char, $ts));
works.

I attached a patch for CalendarUtil.php at revision 89 to this post, that solves this Problem. It is based on http://www.php.net/manual/en/function.utf8-encode.php#89789.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

27 February 2010 at 3:20pm

Wow.. this is excellent. Huge thanks, Beutlin.

Avatar
Beutlin

Community Member, 2 Posts

28 February 2010 at 2:22am

You're welcome. But one more comment: the patch expects, that the target's character set is UTF-8, which is - I suppose - default in Silverstripe. But maybe you can test this using:

ContentNegotiator::get_encoding()

See: http://api.silverstripe.org/sapphire/control/ContentNegotiator.html#get_encoding

Maybe:

$string = strftime($char, $ts);
if (ContentNegotiator::get_encoding() == 'utf-8' && !mb_check_encoding($string, 'utf-8'))
	return utf8_encode($string);
else
	return $string;

Avatar
Juanitou

Community Member, 323 Posts

28 February 2010 at 3:39am

Thanks Beutlin!

Go to Top