Character Encoding

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Character Encoding

Post by jamiel »

Hi all,

Was wondering if it is possible to put together a list of things between PHP, Apache, MySQL and HTML configurations etc. to ensure that if you have say a textarea in your form, to accept all utf-8 characters eg. German Umlaute's , Pound sign's etc. and for the input to go into a MySQL Database using php, and then be retrieved via php and outputted back to the user and provided that their browser is set to UTF-8, for the output to look exactly as they entered it.

To start the list off as an example:

- Make sure the table in MySQL is created with CHARSET=utf-8

I have iconv hacks all over the place to make this happen at the moment, and I believe the reason I have to do this is purely configuration issues or incorrect Meta tags etc.

Any input welcome.

Jamie
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

- Make sure either (a) Your web server send the content-type with a charset specified after it or (b) You specify this in a meta tag in your page.
- If you're hard-coding umlauts etc into PHP scripts, make sure you save the PHP script as UTF-8 with your text editor
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

make sure your db connection is set to use utf. use 'SET NAMES=utf-8'
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Well, you can get away with not setting the DB character encoding in older versions of MySQL (4.0, specifically).
Post Reply