sproctor / php-calendar

PHP-Calendar
http://www.php-calendar.org/
Apache License 2.0
140 stars 67 forks source link

Problem with Swedish character and UTF-8 #88

Closed sagman closed 10 years ago

sagman commented 10 years ago

Thanks for a very good calendar. The interface with the translation into our own language is also very advanced and very user friendly. I have a little problem. I am Swedish and have now then brought down the translated. po and. mo file to my Calendar. It is sad but the Swedish characters are not displayed. Please see here:

http://www.andligt-osc.se/calendar/index.php

The character set used in both phpcdatabase.class.php and index.php is the charset = UTF-8

U+00E5 å c3 a5 LATIN SMALL LETTER A WITH RING ABOVE U+00E4 ä c3 a4 LATIN SMALL LETTER A WITH DIAERESIS U+00F6 ö c3 b6 LATIN SMALL LETTER O WITH DIAERESIS

U+00C5 Å c3 85 LATIN CAPITAL LETTER A WITH RING ABOVE U+00C4 Ä c3 84 LATIN CAPITAL LETTER A WITH DIAERESIS U+00D6 Ö c3 96 LATIN CAPITAL LETTER O WITH DIAERESIS

and then it should of course be right. I realize that you are not able to help anyone who has problems with their Calendar but I wonder if you have any thought about how I could solve this.

Yours sincerely Christer Sagman

sproctor commented 10 years ago

It's been a while since I've tried to tackle character set issues. I just verified that it works fine on my server: http://www.php-calendar.com/php-calendar-dev/index.php?lang=sv That's using the .po file from Transifex, which I assume is yours. Nice job, by the way.

So that leaves me believing there's something different in our setups. A bit of research brought me upon http://www.php.net/manual/en/function.mb-internal-encoding.php . I added a bit of debugging info and found out that my default internal encoding is latin-1, so that probably doesn't matter. The mb_http_output might. If that is set to something other than pass, it might mangle your output. You might want to try some combination of setting mb_internal_encoding to "UTF-8" and mb_http_output to "pass" or "UTF-8".

I added at line 41 of setup.php:

mb_internal_encoding('UTF-8');
mb_http_output('pass');
sagman commented 10 years ago

My ISP is one.com, the use of ISO 8859-1 in MySql, and it can not change it in phpMyAdmin. If I use the default value UTF-8 in PHP-Calendar, I get the Swedish characters I've written in the translation. That will not keep the characters on output from MySql database. the odd Swedish signs come out as (?) . If I instead change the PHP Calendar to ISO 8859-1 arises the inverse relationship. My Swedish characters in the translation vill be replaced with (?). but instead appears properly at output from MySql. It is very annoying. Now I've found another PHP calendar that solves this. My knowledge of programming in PHP and Java is not sufficient to see how they solved it. Is there anyone who has an interest and knowledge to see how they have solved this then there calendar is here: http://webcalendar.cvs.sourceforge.net/viewvc/webcalendar/webcalendar/

sproctor commented 10 years ago

The internal encoding of the database is not important. It can convert to utf8 to output, which is what should be happening. If you have latin1 text in a column with utf8 set as the character set, that would cause the issue.

MySQL, as of 4.1, sets the character set per column not per database. The default character set of your database shouldn't matter.

sagman commented 10 years ago

Thank¨s for your information. Eureka! I finally found the reason why I did not get the characters I missed. For some obscure reason, did the file format changed in the .po file to ansi when I uploaded it to my FTP.