Hi,

I got a web site with lots of french accents. I am not able to get the accents proper even after doing all the functions said in php.net. I tried even user documented ones... utf_decode also do not work:(

How to solve this issue.Request pointers

Thanks.

Dani AI

Generated

As noted by and confirmed by , the problem usually stems from a mismatch between storage, transport and display encodings. Re-importing data into a properly encoded table often resolves symptoms, but the whole stack must be consistent: file encoding, HTTP headers, PHP connection charset, server defaults and column charset. Changing charset blindly on an existing table can corrupt stored bytes, so backups and careful conversion are essential (as warned).

Checklist (in order of likelihood):

  • Files should be saved as UTF-8 without a BOM.
  • HTTP response headers must declare the charset (these override HTML meta tags).
  • Database server, database, table and column charset should be UTF-8 (prefer utf8mb4).
  • The client/connection charset must be set immediately after connecting.
  • Avoid using utf8_decode/utf8_encode unless explicitly converting between UTF-8 and ISO-8859-1.

Common, copy-safe snippets:

header('Content-Type: text/html; charset=utf-8');
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
CREATE TABLE example (
  id INT PRIMARY KEY AUTO_INCREMENT,
  text_col TEXT
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
$mysqli = new mysqli($host,$user,$pass,$db);
$mysqli->set_charset('utf8mb4');
$pdo = new PDO($dsn,$user,$pass,
  [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4"]
);

Troubleshooting tips: inspect raw bytes with bin2hex() in PHP or SELECT HEX(col) in SQL to see whether characters are UTF-8 bytes (e.g. C3A9) or single-byte Latin1 (E9). Use mb_detect_encoding / mb_check_encoding to help identify encodings. If data is double-encoded, work on a copy and restore from backups before attempting SQL CONVERTs. Final goal: store, transmit and render text as UTF-8 (utf8mb4) and set the connection charset explicitly.

Recommended Answers

All 4 Replies

Can you post what you've done? I have a site using UTF-8, and it took me a while to get it sorted out. Is your backend database ALSO utf-8? That made a *huge* difference for me. making sure my takes had default charset utf8

don't try and retro-actively change the charset, it'll wipe out the data. instead create a new table utf8, and select into it. then rename it.

commented: perfect! I solved this part. +3

Can you post what you've done? I have a site using UTF-8, and it took me a while to get it sorted out. Is your backend database ALSO utf-8? That made a *huge* difference for me. making sure my takes had default charset utf8

don't try and retro-actively change the charset, it'll wipe out the data. instead create a new table utf8, and select into it. then rename it.

I tried. yep, i build a new database and tried to insert the data. No help.

sorry , by the way thanks for the patience and the pointer. Happy weekend..

Thanks once again

hari

I tried. yep, i build a new database and tried to insert the data. No help.

sorry , by the way thanks for the patience and the pointer. Happy weekend..

Thanks once again

hari

hi ,

Again a "Hi". Thanks. Yeah.. u said it right. i created a new DB and then imported the sql ith utf8.

It helped.

Thanks once again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.