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

  • SEARCH
  • Home
  • 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 1014851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:18:46+00:00 2026-05-16T10:18:46+00:00

I want to use utf 8 right now , but all my data is

  • 0

I want to use utf 8 right now , but all my data is latin1 , what is the efficient way to convert data . Also I know how to change database’s structure(charset) to utf8 , What I want to do is changing charset of existing data .

update

Here are my old setting ,

  1. Html output : utf8
  2. Html input : utf8
  3. Php – mysql connection : latin1
  4. mysql (fields and tables) : latin1

Here are my new settings , and I hope this is the best way to create multi-language website

  1. Html output : utf8
  2. Html input : utf8
  3. Php – mysql connection : utf8
  4. sql (fields and tables) : utf8
  • 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-16T10:18:47+00:00Added an answer on May 16, 2026 at 10:18 am

    If you apply utf8_encode() to an already UTF8 string it will return a garbled UTF8 output.

    I made a function that addresses all this issues. It´s called forceUTF8().

    You dont need to know what the encoding of your strings is. It can be Latin1 (iso 8859-1) or UTF8, or the string can have a mix of the two. forceUTF8() will convert everything to UTF8.

    I did it because a service was giving me a feed of data all messed up, mixing UTF8 and Latin1 in the same string.

    Usage:

    $utf8_string = forceUTF8($utf8_or_latin1_or_mixed_string);
    
    $latin1_string = forceLatin1($utf8_or_latin1_or_mixed_string);
    

    I’ve included another function, fixUFT8(), wich will fix every UTF8 string that looks garbled.

    Usage:

    $utf8_string = fixUTF8($garbled_utf8_string);
    

    Examples:

    echo fixUTF8("Fédération Camerounaise de Football");
    
    echo fixUTF8("Fédération Camerounaise de Football");
    
    echo fixUTF8("FÃÂédÃÂération Camerounaise de Football");
    
    echo fixUTF8("Fédération Camerounaise de Football");
    

    will output:

    Fédération Camerounaise de Football
    
    Fédération Camerounaise de Football
    
    Fédération Camerounaise de Football
    
    Fédération Camerounaise de Football
    

    Update: I converted theese into a static class, and they live in Github now:

    https://github.com/neitanod/forceutf8

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

Sidebar

Related Questions

i want use some data from a website with web service. i have a
I want use JQuery mobile for the front-end of my mobile application, but I
I want use jQuery in my project. I know the javascript_include_tag calls the jQuery
I want to use the look of standard buttons on my page, but I
I got a PHP & MySQL script that use windows-1256 charset, I now want
I want to set my Django site to use UTF-8 for MySQL in a
I want use groovy findAll with my param to filtering closure filterClosure = {
I have a transaction log file in CSV format that I want use to
I have a easy select tag: <select> <option></option> <option></option> </select> Then I want use
I want to use ADO.NET Prepare command will increase performance if query is repeatevely

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.