KubiRoazhon
KubiRoazhon

Reputation: 1839

How to encode characters with accents in PHP

My issue is so simple. I have to make some Get query to a web service, when I put a text data with some special characters é or à I get a ? character instead of the originals. I've tried this two function urlencode() / rawurlencode(). The two of the them are not giving me what I want. My question is how can get a text like this to my query 3+rue+égbelle and not 3+rue+?gbelle.

That's all.

Upvotes: 0

Views: 614

Answers (1)

user1134181
user1134181

Reputation:

Check your php.ini, file encoding and header definitions.

For multibyte characters you should specify in php.ini the following:

default_charset = "UTF-8";

It will be the default character set that is used by many PHP functions.

The same value will be added to the Content-Type header if other is not specified by using header() function:

header('Content-Type: text/html; charset=utf-8');

In the file you should use:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

Upvotes: 1

Related Questions