Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 344567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:00:09+00:00 2026-05-12T11:00:09+00:00

I am in the process of fixing some bad UTF-8 encoding. I am currently

  • 0

I am in the process of fixing some bad UTF-8 encoding. I am currently using PHP 5 and MySQL.

In my database I have a few instances of bad encodings that print like: î

  • The database collation is utf8_general_ci
  • PHP is using a proper UTF-8 header
  • Notepad++ is set to use UTF-8 without BOM
  • database management is handled in phpMyAdmin
  • not all cases of accented characters are broken

I need some sort of function that will help me map the instances of î, í, ü and others like it to their proper accented UTF-8 characters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:00:10+00:00Added an answer on May 12, 2026 at 11:00 am

    I’ve had to try to ‘fix’ a number of UTF8 broken situations in the past, and unfortunately it’s never easy, and often rather impossible.

    Unless you can determine exactly how it was broken, and it was always broken in that exact same way, then it’s going to be hard to ‘undo’ the damage.

    If you want to try to undo the damage, your best bet would be to start writing some sample code, where you attempt numerous variations on calls to mb_convert_encoding() to see if you can find a combination of ‘from’ and ‘to’ that fixes your data. In the end, it’s often best to not even bother worrying about fixing the old data because of the pain levels involved, but instead to just fix things going forward.

    However, before doing this, you need to make sure that you fix everything that is causing this issue in the first place. You’ve already mentioned that your DB table collation and editors are set properly. But there are more places where you need to check to make sure that everything is properly UTF-8:

    • Make sure that you are serving your HTML as UTF-8:
      • header("Content-Type: text/html; charset=utf-8");
    • Change your PHP default charset to utf-8:
      • ini_set("default_charset", 'utf-8');
    • If your database doesn’t ALWAYS talk in utf-8, then you may need to tell it on a per connection basis to ensure it’s in utf-8 mode, in MySQL you do that by issuing:
      • charset utf8
    • You may need to tell your webserver to always try to talk in UTF8, in Apache this command is:
      • AddDefaultCharset UTF-8
    • Finally, you need to ALWAYS make sure that you are using PHP functions that are properly UTF-8 complaint. This means always using the mb_* styled ‘multibyte aware’ string functions. It also means when calling functions such as htmlspecialchars(), that you include the appropriate ‘utf-8’ charset parameter at the end to make sure that it doesn’t encode them incorrectly.

    If you miss up on any one step through your whole process, the encoding can be mangled and problems arise. Once you get in the ‘groove’ of doing utf-8 though, this all becomes second nature. And of course, PHP6 is supposed to be fully unicode complaint from the getgo, which will make lots of this easier (hopefully)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the process of fixing a poorly imported database with issues caused by using
I recently did some performance testing and analysis of an ASP.NET application using out-of-process
I have experienced some troubles when using the IIS server at my workstation with
I have this open-source library that I'm having some trouble fixing a problem... This
I have a process which has a notify method which receives as a parameter
I have a process which gives me continuously output in Screen. I want to
I have been assigned to work on some legacy C++ code in MFC. One
I have a long-running process where, due to a bug, a trivial/expendable thread is
I am using PrototypeJS's e.stop() function in a click observer, which I do some
I'm in the process of going back over some of the more minor TODO's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.