Page 1 of 1

Problem with special characters in calendar (Bulletproof)

Posted: Fri Feb 13, 2009 4:19 am
by alemartini
I'm setting up a new blog using s9y 1.3.1 with the Bulletproof style. The site is in spanish, and every special character is being displayed as it should, with just one small but annoying exception: the calendar plugin.

At the top of the calendar, you can see the names of the days shortened to two characters. Each of the days is OK, except for "Sábado" (Saturday), which should be displayed as "Sá", but it's actually shown as "S?" (a capital S followed by a question mark enclosed in a diamond shape).

I guess that there must be some problem with the calendar plugin when the blog has been set up for a foreign language. However, I still can't find what is causing the problem or how to fix it.

Any ideas on how to solve this?


Thanks in advance!,
Alex

Re: Problem with special characters in calendar (Bulletproof)

Posted: Fri Feb 13, 2009 10:29 am
by garvinhicking
Hi!

Yes, this is because your server does not seem to have the spanish UTF-8 locale installed (usually es_ES.UTF-8). You could ask your provider if he can install all spanish UTF-8 locales.

Regards,
Garvin

Re: Problem with special characters in calendar (Bulletproof)

Posted: Fri Feb 13, 2009 12:50 pm
by alemartini
Hi Garvin,

I've checked the hosting account and it does provide the UTF-8 spanish locale.

If I publish a post on a Saturday, the date on the post shows OK as "Sábado". Even on the calendar, the tooltip for "S?" displays "Sábado".

I made a very simple php file in order to test this:

Code: Select all

setlocale (LC_TIME, 'es_ES.utf8');
echo "Saturday: ".strftime ("%A",  mktime(0,0,0,02,14,2009));
echo "<br>Sat: ".strftime ("%a",  mktime(0,0,0,02,14,2009));
The code above displays the following:

Code: Select all

Saturday: sábado
Sat: sáb
So I guess there must be something wrong with the calendar plugin, since everything else is working as expected.

BTW, the HTML source code for the calendar looks like this:

Code: Select all

<th id="Sá" scope="col" abbr="Sábado" title="Sábado" class="serendipity_weekDayName" align="center">S�</th>
Is there anything else I should check?


Thanks again,
Alex

Re: Problem with special characters in calendar (Bulletproof)

Posted: Fri Feb 13, 2009 1:53 pm
by garvinhicking
Hi!

Ah, I think I know what's happening. Some plugin_Calendar.tpl files uses "truncate" to only get the first X characters. However in UTF-8 this will split one special char in half, so you would need to truncate by 3 characters instead of 2...

HTH,
Garvin

Re: Problem with special characters in calendar (Bulletproof)

Posted: Fri Feb 13, 2009 7:31 pm
by alemartini
If I change the truncate call in plugin_calendar.tpl so that it keeps 3 characters instead of 2, then Wednesday is shown as "Mi?" (it's spelled "Miércoles" in spanish).

But knowing where the problem is, I looked for issues related to Smarty, truncate and UTF-8 strings, and found a workaround here:

Multibyte String Truncate Modifier for Smarty - mb_truncate

I don't know if there's a better way to solve this, but I've followed the steps in that post, and it worked like a charm.

Thank you for pointing me in the right direction!


Best regards,
Alex

Re: Problem with special characters in calendar (Bulletproof)

Posted: Fri Feb 13, 2009 8:10 pm
by judebert
Perhaps we should add a mb_truncate modifier to the ones s9y supplies.

Re: Problem with special characters in calendar (Bulletproof)

Posted: Fri Feb 13, 2009 9:15 pm
by Don Chambers
judebert wrote:Perhaps we should add a mb_truncate modifier to the ones s9y supplies.
I second the motion....

Re: Problem with special characters in calendar (Bulletproof)

Posted: Sat Feb 14, 2009 5:54 pm
by garvinhicking
Hi!

Sadly mbstring is not always existing, so a fallback method needs to be employed.

Regards,
Garvin

Re: Problem with special characters in calendar (Bulletproof)

Posted: Sat Feb 14, 2009 11:04 pm
by brr
I have got the same problem with Norwegian characters in the calendar. Saturday = Lørdag, Sunday = Søndag. The character ø gives the calendar problems.

Re: Problem with special characters in calendar (Bulletproof)

Posted: Fri Mar 13, 2009 9:03 pm
by alemartini
After performing an upgrade to s9y 1.4.1, the calendar in Bulletproof broke again :?

After the upgrade I applied the workaround that I mentioned before, but this time it isn't working (the calendar is showing "S?" where it should display "Sá").

I can tell for sure that this isn't a problem with PHP or my hosting environment, since if I run the code shown below, it shows all the strings perfectly.

Code: Select all

setlocale (LC_TIME, 'es_ES.utf8');
echo "Saturday: ".strftime ("%A",  mktime(0,0,0,02,14,2009));
echo "<br>Sat: ".strftime ("%a",  mktime(0,0,0,02,14,2009));
echo "<br>Sa: ".mb_substr(strftime ("%a",  mktime(0,0,0,02,14,2009)), 0, 2, 'UTF-8');
So, is there any way to solve this problem in s9y?


Edit : on IE the calendar output looks even worse. The first line displays "Do Lu Ma Mi Ju Vi Sü/th>" . And here's the source that IE shows:

Code: Select all

<th id="Dom" scope="col" abbr="Domingo" title="Domingo" class="serendipity_weekDayName" align="center">Do</th>
            <th id="Lun" scope="col" abbr="Lunes" title="Lunes" class="serendipity_weekDayName" align="center">Lu</th>
            <th id="Mar" scope="col" abbr="Martes" title="Martes" class="serendipity_weekDayName" align="center">Ma</th>
            <th id="MiÃ" scope="col" abbr="Miércoles" title="Miércoles" class="serendipity_weekDayName" align="center">Mi</th>
            <th id="Jue" scope="col" abbr="Jueves" title="Jueves" class="serendipity_weekDayName" align="center">Ju</th>
            <th id="Vie" scope="col" abbr="Viernes" title="Viernes" class="serendipity_weekDayName" align="center">Vi</th>
            <th id="Sá" scope="col" abbr="Sábado" title="Sábado" class="serendipity_weekDayName" align="center">SÃ</th>

Re: Problem with special characters in calendar (Bulletproof)

Posted: Fri Mar 13, 2009 9:35 pm
by alemartini
Well, after opening plugin_calendar.tpl and saving it (without changing a single byte), everything went back to normal.

A server-side caching problem maybe? I'm not sure. I don't even know why it stopped working in the first place. But fortunately, the calendar is now working as expected :) (tested with Opera, FF and IE).