Created
November 29, 2011 22:24
-
-
Save mitchellhislop/1406858 to your computer and use it in GitHub Desktop.
Removing special characters in MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FIRST, REPLACE UTF-8 characters. | |
UPDATE `t` SET `c` = REPLACE(`c`, 0xE28098, "'"); | |
UPDATE `t` SET `c` = REPLACE(`c`, 0xE28099, "'"); | |
UPDATE `t` SET `c` = REPLACE(`c`, 0xE2809C, '"'); | |
UPDATE `t` SET `c` = REPLACE(`c`, 0xE2809D, '"'); | |
UPDATE `t` SET `c` = REPLACE(`c`, 0xE28093, '-'); | |
UPDATE `t` SET `c` = REPLACE(`c`, 0xE28094, '--'); | |
UPDATE `t` SET `c` = REPLACE(`c`, 0xE280A6, '...'); | |
# NEXT, REPLACE their Windows-1252 equivalents. | |
UPDATE `t` SET `c` = REPLACE(`c`, CHAR(145), "'"); | |
UPDATE `t` SET `c` = REPLACE(`c`, CHAR(146), "'"); | |
UPDATE `t` SET `c` = REPLACE(`c`, CHAR(147), '"'); | |
UPDATE `t` SET `c` = REPLACE(`c`, CHAR(148), '"'); | |
UPDATE `t` SET `c` = REPLACE(`c`, CHAR(150), '-'); | |
UPDATE `t` SET `c` = REPLACE(`c`, CHAR(151), '--'); | |
UPDATE `t` SET `c` = REPLACE(`c`, CHAR(133), '...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment