I recently switched to another platform for my personal site, and I had a problem when the previous character encoding, such as ", ""and ', is now transcoded strangely, like:
&
&
&
’
&
I have seen this before, and the last time I looked through manually and updated each article. However, this time I would like to take a more pragmatic approach by updating the database.
How could I replace all occurrences of these lines with my correct character?
I think it will look like:
SELECT REPLACE(''',''')
But do you have to be careful and include escape characters like \? Also, how do I perform this type of replacement across the entire database?
. phpMyAdmin , , "SQL". , , MySQL .
Update:
:
- - "field_data_comment_body"
- : "comment_body_value"
- , , "longtext"
Johan, 0 :
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;
: , 63 :
SELECT `comment_body_value`
FROM `field_data_comment_body`
WHERE `comment_body_value` LIKE '%&#039;%'
LIMIT 0 , 30