Jump to content

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/183636-problem-with-umlauts-and-utf-8/
Share on other sites

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.

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

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'. :)

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 ;)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.