Removing strange characters from MySQL data

Somewhere along the way, between all the goods I import and export, the majority of the text on the blog I am running is full of strange accented characters. For instance:

http://teamsoell.com/andy/petnames (riveting content, I know)

When I export data using mysqldump and load it into a text editor with the intention of using search and replace to clear bad characters, the search simply matches each character “a”.

Does anyone know how I can successfully track these characters and get rid of them, either directly in MySQL, or using mysqldump, and then re-import the content?

+5
source share
3 answers

; Â - ( HTML  ) , 1.

- ... , , :

SELECT * FROM some_table WHERE some_field LIKE BINARY '%Â%'

some_table, some_field . , , , , :

UPDATE some_table SET some_field = REPLACE( some_field, BINARY 'Â', '' )

( , , nbsp , .., ).

, .

EDIT: BINARY ; .

+8

, , . , , , :   â € œ , - , (, ), MySQL, .

Wordpress, , , Wordpress http://digwp.com/2011/07/clean-up-weird-characters-in-database/

, , - . , MySQL, , .

0

.

From here http://nicj.net/mysql-converting-an-incorrect-latin1-column-to-utf8/ I found that the binary code for the symbol  is c2a0 (by converting the column to VARBINARY and viewing it turns into). Then here http://www.oneminuteinfo.com/2013/11/mysql-replace-non-ascii-characters.html the actual solution for removal (replacement) is found:

update entry set english_translation = unhex(replace(hex(english_translation),'C2A0','20')) where entry_id = 4008;

The above query replaces it with a space, then normal trimming can be applied or just replaced with '' instead.

0
source

All Articles