AD1ctive Posted December 1, 2009 Share Posted December 1, 2009 Hello every1, I'm creating my own little CMS at the moment and got some problems with the charset. I decided to use UTF-8 so that I don't have to switch between charsets when using different languages. When I look at the page now, there are, however, ? instead of SOME of the umlauts. All the afftected ones come either from the database or aren't in the main template but an included one. Before the page is being displayed by the Smarty Template system the CMS sends a header with the charset UTF-8. The templates contain the attribut encoding="UTF-8" as well. Then I set all the database charsets in phpmyadmin to UTF-8-general-ci but it still doesnt't work. Can the problem be that the php files themselves are saved in the ANSI format?! Which one do I have to choose instead? Notepad offers Unicode, Unicode big endian and UTF-8. Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/183636-problem-with-umlauts-and-utf-8/ Share on other sites More sharing options...
cags Posted December 2, 2009 Share Posted December 2, 2009 I don't know anything about smarty itself or how it works, but the problem could be ANSI storage of the file, you should set that to UTF-8. If you are fetching information from a database you may also need to send the queries "SET CHARACTER SET utf-8" and/or "SET NAMES utf-8" after connecting to the database. Quote Link to comment https://forums.phpfreaks.com/topic/183636-problem-with-umlauts-and-utf-8/#findComment-969677 Share on other sites More sharing options...
AD1ctive Posted December 2, 2009 Author Share Posted December 2, 2009 Thanks for your help. I ran your commands after selecting the database and it actually worked. But isn't there a way to set utf8 as default charset so that I don't have to run those to queries everytime a page is called?! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/183636-problem-with-umlauts-and-utf-8/#findComment-969839 Share on other sites More sharing options...
cags Posted December 2, 2009 Share Posted December 2, 2009 Not that I know of. Since you have to call mysql_connect and mysql_select_db on every page anyway, it's not like it'll matter too much. Just have a connect script that you can include that does all 3-4 things. Quote Link to comment https://forums.phpfreaks.com/topic/183636-problem-with-umlauts-and-utf-8/#findComment-969849 Share on other sites More sharing options...
JonnoTheDev Posted December 2, 2009 Share Posted December 2, 2009 Not that I know of Yes there is. You can set in your mysql configuration (my.cnf) or use the charset command via the mysql cli. Read the following documentation. http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html Quote Link to comment https://forums.phpfreaks.com/topic/183636-problem-with-umlauts-and-utf-8/#findComment-969853 Share on other sites More sharing options...
cags Posted December 2, 2009 Share Posted December 2, 2009 Not that I know of Yes there is. You can set in your mysql configuration (my.cnf) or use the charset command via the mysql cli. Read the following documentation. http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html I figured there logically might be, hence the fact I didn't say 'No'. Quote Link to comment https://forums.phpfreaks.com/topic/183636-problem-with-umlauts-and-utf-8/#findComment-969855 Share on other sites More sharing options...
AD1ctive Posted December 2, 2009 Author Share Posted December 2, 2009 I had a look through the page and ran those two commands: SHOW VARIABLES LIKE 'character_set%'; SHOW VARIABLES LIKE 'collation%'; The result: all vars are set to utf8 apart from the character_set_server and the collation_server one. I guess I cannot access those but according to the manual they are only used when creating a database. If I got it right, all my default charsets are set to utf8 so where could the other character set come from? I also set the collation of the tables and coloumns to utf8_general_ci and the charset to utf8 - so that shouldn't be the problem. Does the function mysql_connect() have a flag for the charset which is latin1 by default? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/183636-problem-with-umlauts-and-utf-8/#findComment-969896 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.