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 5930691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:35:20+00:00 2026-05-22T14:35:20+00:00

I’ve recently moved to a different platform for my personal website, and I’ve run

  • 0

I’ve recently moved to a different platform for my personal website, and I’ve run into a problem where the previous encoding of characters such as ", "", and ' are now recoded strangely as:

“
”
’
’
'

I’ve seen this before, and last time, I went through manually and updated each article. This time, however, I’d like to take a more pragmatic approach by updating the database.

How would I go about replacing all occurences of these strings with their correct character?

I’m thinking that it would be somehting like:

SELECT REPLACE(''',''')

But do I need to be cautious and include escape characters like \? Also, how would I perform this type of replacement across the entire database?

Note: I’ll be using phpMyAdmin to perform these replacements, so I’m hoping that it’s just a matter of typing a series of commands into the “SQL” tab. Although, I do have access to the MySQL server from the command line if it’s necessary.

Update:

More about the structure:

  • The table name is “field_data_comment_body”
  • The field name is “comment_body_value”
  • The field in question is of type “longtext”

I’ve tried running Johan’s recommendation, but it returns 0 Affected rows:

DELIMITER $$

CREATE FUNCTION FixEncoding(input longtext) RETURNS longtext
BEGIN
  DECLARE output longtext;

  SET output = input;   
  SET output = REPLACE(output,''','\'');
  SET output = REPLACE(output,'’','\'');
  SET output = REPLACE(output,'” ','"');
  SET output = REPLACE(output,'“','"');
  SET output = REPLACE(output,'’','\'');

  RETURN output;
END $$

DELIMITER ;

UPDATE field_data_comment_body SET comment_body_value = FixEncoding(comment_body_value) WHERE entity_id <> 0;

Update: It’s not a translation error as this returns 63 rows:

SELECT  `comment_body_value` 
FROM  `field_data_comment_body` 
WHERE  `comment_body_value` LIKE  '%&amp;#039;%'
LIMIT 0 , 30
  • 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-22T14:35:21+00:00Added an answer on May 22, 2026 at 2:35 pm

    In MySQL characters can be escaped by using \.

    I’d write a function to do the replacing for you and than do an update, something like this.

    DELIMITER $$
    
    CREATE FUNCTION FixEncoding(input varchar) RETURNS varchar
    BEGIN
      DECLARE output varchar;
    
      SET output = input;   
      SET output = REPLACE(output,'&#039;','\'');
      SET output = REPLACE(output, .....
      .....
    
      RETURN output;
    END $$
    
    DELIMITER ;
    
    UPDATE table1 SET column1 = FixEncoding(Column1) WHERE id <> 0;
    

    If this doesn’t work then you might be suffering from translation issue between the database and the presentation layer.
    Make a backup of your database
    and change the encoding of your table(s) by using:

    ALTER TABLE `test`.`test` CHARACTER SET latin1 COLLATE latin1_general_ci;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.