Ripefruit

  • About Us
    • About Us
      • Acceptable Use
      • Privacy Policy
      • T & C
    • Contact Ripefruit
    • In Progress
    • Not For Profit
    • Partners
  • What We Do!
    • Advertising
    • Publications
    • Web Design
  • Clients
    • Billing
    • Client Login
    • Resources
      • Friends
      • Service Status
    • Support
  • IT Talk
    • Domain Names
    • Hosting
    • Internet
    • Search
    • Services
    • Software
    • Technical
  • Contact Us
    • Contact Us
    • Site Map
You are here: Home / IT Talk / Publishing / How We Solved a Encoding Issue (Thanks to ChatGPT)

How We Solved a Encoding Issue (Thanks to ChatGPT)

For over two years, we wrestled with a bizarre issue in our custom-built CMS — corrupted symbols like:

â€, “, ”, ”, ’, ', ‘, ™, •, ®, —, –, ¯, ‰ (and many others)

These strange characters replaced quotation marks, apostrophes, trademark symbols, and more. It was not only ugly — it was affecting content quality and search engine results.

Even more confusing: two identical sites using the same CMS and the same database setup showed different results.

One displayed characters perfectly, the other replaced them with garbage.

We consulted:

  • Programmers

  • Database specialists

  • Web developers

  • Industry veterans

🧠 Nobody could fix it.


🔍 The Early Assumptions & Investigations

The obvious first step was checking encoding:

  • ✅ Meta tags in the HTML: UTF-8

  • ✅ Database collation: utf8_general_ci

  • ✅ File encoding: saved as UTF-8 (no BOM)

  • ✅ Symbol entities: encoded properly (’, ™, etc.)

We tried:

  • Converting special characters to entities

  • Using htmlspecialchars, htmlentities, etc.

  • Changing how files were saved (ANSI → UTF-8)

  • Forcing charset headers in the HTML and HTTP

Yet… the problem persisted.


🧩 The Turning Point — ChatGPT

While working on something unrelated (email HTML layout and simplification), we stumbled back onto the encoding issue. As we casually mentioned the symbol corruption again, ChatGPT zeroed in on something critical:

“Have you set the character set for your MySQL connection?”

💡 It suggested:

mysqli_set_charset($db, “utf8mb4”);

We added this line immediately after connecting to the database:

$db = mysqli_connect("host", "user", "pass", "dbname");mysqli_set_charset($db, "utf8mb4");

🎉 Instant fix. Symbols rendered perfectly — consistently — on both sites.

✅ Why This Works
By default, some MySQL setups use latin1 as the character set for client-server communication. Even if your database and tables are in utf8, if the connection uses latin1, characters get corrupted on the way in or out.

Setting the connection to utf8mb4 ensures:

Full Unicode support (including emoji and rare symbols)

Accurate character transmission between MySQL and PHP

🧠 Final Fix
Just add this after establishing the database connection:

$db = mysqli_connect("host", "user", "pass", "dbname");mysqli_set_charset($db, "utf8mb4");

And make sure your:

HTML is correct

Files are saved as UTF-8 (without BOM)

Database/table columns are utf8mb4_general_ci (or similar)

🙌 A Massive Thanks to ChatGPT
We’ve had talented people look at this issue for years — but it took a little AI magic to see the real problem.

💬 ChatGPT didn’t just give an answer — it:

  • Asked the right questions
  • Suggested multiple avenues to explore
  • Never gave up on finding the real cause
  • Finally nailed the solution with a single line of PHP

Thank you, ChatGPT — you saved us!

  • https://chat.openai.com/

Encoding Issue Fix for â€, “, ”, ”, ’, ‘, ‘, ™, •, ®, —, –, ¯

mysqli_set_charset($db, "utf8mb4");

Author note: I included the characters in this post multiple times to help anyone searching for an answer. We tried everthing with the hardest part being finding posts/pages discussing the issue. Yes, I found lots of suggestions but only this one actually resolved it.

Oh, and in case it doesn’t fix your issue, run this query in phpmyadmin and it will remove/replace the bad characters in your content. You will have to change two things: table_name and field_name.

  • Download (TXT) Notepad file


Please LIKE or tell a friend..



Post Views: 176

Also See..


  • Fixing WordPress Speed Issue
  • Your Site is Experiencing a Technical Issue: NextGEN Gallery FIX
  • Spam Idea: Outsmarting Spammers
  • Saved by WordPress AUTOSAVE
  • WS_FTP LE | Profiles Missing

Recent Posts

  • How We Solved a Encoding Issue (Thanks to ChatGPT)
  • Windows 11 Not Seeing Keyboard at PIN Login = Fix
  • WooCoomerce: Buy Now + Affiliate Link + Cart – FIXED

About Brian King

Managing director and senior editor at Ripefruit Media

  • Email
  • Facebook
  • Twitter
  • YouTube

For Advertisers

  • Advertising FAQ
  • Contact Us
  • Content Changes
  • Website Network

IT Talk

  • How We Solved a Encoding Issue (Thanks to ChatGPT)
  • Windows 11 Not Seeing Keyboard at PIN Login = Fix
  • WooCoomerce: Buy Now + Affiliate Link + Cart – FIXED
  • Why WP Engine Affiliate program migration from ShareASale to Everflow is a WASTE of time
  • how to hide nvidia pop up
  • Facebook Wishlist: Edit Featured Pin’s
  • What is the best shopping cart?
  • file explorer not responding FIX

Keywords

admin affiliation attack australian avg brute force business cache change domain name ebay email facebook fix form for sale fraud google hosting how to htaccess image ip ip address LastPass mobile password Phishing pin plugin ranking removal remove responsive scam security seo software spam toontown web site website Wordfence wordpress wpmu dev

SiteMap

  • About Us
  • Acceptable Use Policy
  • Advertising
  • Contact Us
  • Digital Publications
  • Domain Names
  • Email
  • Home Page
  • Hosting
  • Internet
  • Publishing
  • Software
  • Technical
  • Search
  • Services
  • Web Design
  • About Us
  • What We Do!
  • Clients
  • IT Talk
  • Contact Us


Copyright © 2025 · Ripefruit

Ripefruit acknowledges and pays respect to Aboriginal and Torres Strait Islander Elders past, present and future. We commit to building a kind future for everyone.