omg
omg

Reputation: 140112

How to make internal processing encoding change to UTF8 in PHP?

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?

Upvotes: 1

Views: 3079

Answers (2)

Jijo K Jose
Jijo K Jose

Reputation: 1

You can change the character encoding in php file. To change encoding in php page use the following function.

$new_value = htmlentities('$old_value',ENT_COMPAT, "UTF-8");

and also you can add the following in the html head section

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

I hope this will help to solve your problem.

Upvotes: 0

bucabay
bucabay

Reputation: 5295

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.

Upvotes: 4

Related Questions