views:

306

answers:

1

Currently in my application the utf8 encoded data is spoiled by internal coding of PHP.

How to make it consistent with utf8?

EDIT:To show examples,please tell me how to output the current internal encoding in PHP?

In php.ini I found the following:

default_charset = "iso-8859-1"

Which means Latin1.

How to change it to utf8,say,what's the iso version of utf8?

A: 

Change it to:

default_charset = "utf-8"

There is no ISO version of UTF-8.

You'll need to be specific with the details since encoding can be mangled at many different areas in your PHP application. The common problem areas are:

Saving and retrieving from DB: The database encoding must the same as the strings sent to it from PHP, or you must convert the strings to the DB encoding.

PHP4's single byte string functions: PHP's functions such as strlen(), str_replace() do not produce the correct results on multibyte encodings such as UTF-8, since they operate on single bytes.

Page encoding: Make sure the browser knows you are sending it UTF-8.

bucabay
Isn't utf-8 the same as iso-10646-1?For "PHP4's single byte string functions",you mean replace all those string functions to mb_ functions?
Shore
iso-10646-1, didn't know that. I wouldn't set the configuration to iso-10646-1 though. Yes, use the mb_functions for PHP4. PHP5 has native support for UTF-8.
bucabay
For PHP4 see: http://www.phpwact.org/php/i18n/utf-8
bucabay