distal-attribute
distal-attribute
distal-attribute
distal-attribute

Which charset, DTD & encoding to use?

User, date Message
Written by westmatrix
6 years ago
Category: General
82 posts since Wed, 11 Apr 07
I use this below, but get funny chars like this; Feb
Written by ansgar
6 years ago
4986 posts since Fri, 07 Apr 06
How was this file created? It's obviously not HeidiSQL, as we don't export a meta-charset (yet... would be a good idea though)
Written by kalvaro
6 years ago
593 posts since Thu, 29 Nov 07
My guess is that you are developing a web site with a MySQL backend, possibly written in PHP.

The web server must tell the browser what charset the document uses via a "Content-Type" HTTP header. You have many options to do so. I've you're actually using PHP, you can generate the header yourself:

<?php header('Content-Type: text/html; charset=utf8'); ?>



If you are using Apache, you can do it in an .htaccess file:

AddDefaultCharset utf-8

Written by rosenfield
6 years ago
127 posts since Wed, 24 Jan 07
Putting the character set in a meta header inside the file is actually NOT a good idea.

This is because the character set must match the actual format the file is written in. You would need to manually keep them in sync.

If you're editing a file, use an editor capable of writing UTF-8 files. A file written in utf8 format will contain a three-byte header which the editor will automatically maintain without you having to do anything.

If you're serving files with a web server, the scripting engine (PHP, for example) should have an option where you can set which character set you want to serve to clients, usually latin1, utf8 or cp1252. The scripting engine will then set the correct Content-Type header to include the character set, and send it out in the HTTP header to match the HTTP contents it generates.

Also, talking about a combination of the above. If you use a text editor that puts the correct utf8 header in files you edit, and if those files are PHP files, then the PHP engine should recognize that the file it is compiling is in utf8, and translate text inside on-the-fly to whatever format you told PHP you'd like to serve to clients.

Hope it makes sense.
Written by westmatrix
6 years ago
82 posts since Wed, 11 Apr 07
Thanks
 

Please login to leave a reply, or register at first.