OpenEMR UTF-8 Upgrade Howto

From OpenEMR Project Wiki

OpenEMR 3.1.0 is 100% UTF-8 compliant to allow special character languages (such as chinese, greek, etc.), however users that are upgrading from a previous version of OpenEMR will continue to have a hybrid UTF-8/latin1 database and thus won't have 100% UTF-8 compliance. Several ways to go for upgraders:

(If decide to convert to UTF8, ensure you backup the database before conversion.)

1) If your only using english characters currently and plan on only using English characters in the future, then doing a simple OpenEMR upgrade will suffice (no need to convert to database to 100% UTF-8).

2) If your only using english characters, however, plan to use a language with any special non-english characters in the future, then you should consider converting your database to 100% UTF-8. In this special case (since you were only using english characters previously) then a simple conversion will work. So, you would do the simple OpenEMR upgrade discussed elsewhere and then do following two command line commands on your upgraded database (assuming database name is openemr):

mysql -u rootuser -p --database=openemr -B -N -e "SHOW TABLES" | awk '{print "ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8;"}' | mysql --database=openemr &
mysql -e "ALTER DATABASE openemr CHARACTER SET utf8;"
(NOTE that above will alter your database and could possibly screw it up, so BACK IT UP first)


3) If your currently using non-english characters, and want to continue supporting non-english characters. This is the hard one, because OpenEMR's previous releases did not do a very good job maintaining consistent encoding in the database (a very common problem in other software also). You could try above strategt in number 2, however you have a possibility of getting garbage. If 2) doesn't work, then you will likely need to go a strategy like the following linked below:
http://codex.wordpress.org/Converting_Database_Character_Sets

To repeat:

---This only pertains to users that are upgrading (users that are installing 3.1.0 new do not need to worry about this stuff)
---Upgraders that are only planning to use english characters do not need to worry about this stuff. (unless you want to be cool, and say your using OpenEMR with 100% UTF-8 compliance...)