Whenever I try to save an address with non-ascii characters like:
721-1 Higashishiokōjichō, Shimogyō-ku, Kyoto, 600-8216, Japan
Mysql fails with an error:
OperationalError(1366, "Incorrect string value: '\\xC5\\x8Djich...' for column 'formatted_address' at row 1")
What is the best practice to save foreign language characters in database? Should I just ignore these characters in code? Or find a way to store them in MySQL (how?) ?
EDIT:
Ok after reading few articles, I tried changing the formatting of my database column from latin1
to utf8
. But the query just hangs and times out. Can anyone help?
ALTER TABLE <MYTABLE> MODIFY formatted_address TEXT CHARACTER SET utf8 COLLATE utf8_general_ci;
SOLVED: this worked :) -> https://stackoverflow.com/a/6115705/3520404