dodoskido powered by

Where to find Vista SP1 download :: home :: The Nerd Handbook (or What Makes Me Tick)


* MySQL Chinese Character Fix (or how to make UTF-8 work for you pages) *
comments

Time to go into nerd mode for a bit. Sorry...read this if you want to know why this is happening.

So, Hongyun's new site BubbaNotes.com is getting more users and we've decided to set up a bulletin board system so everyone can get to know each other better and have discussions about learning English. Anyway, I've been trying to get the Simple Machines Forum (which is simply phenomenal in my opinion) to understand Chinese characters. At first, I was able to switch the default character set to chinese simplified utf 8 and everything "just worked"--wow! Then for my own user account, I was able to switch to English which is really cool--each user can have their own UI preference as long as the theme supports it. Anyway, the problem came when I tried to input Chinese into the board. No matter what I did, I got back question marks ("???") instead of the actual Chinese characters. WTF? I thought. So I started digging...and digging...and digging as I normally do in these situations. I eventually stumbled upon Nixser's Solution For MySQL UTF-8 Encoded Data Unreadable In Web Pages..

In case you this page disappears, I've mirrored the info here:


Solution
I’ve solved the problem with phpmyadmin, with the inspiration from this MySQL Doc. I am not sure if my host has upgraded the MySQL server recently or not, but this method worked out for me. Note that I’ve tried to import the same database into my local debian box, the problem still occured and same work needed to be done. Now here’s how it’s solved.Warning, backup everything before making any changes, universal rule!

First, you have to know where’s the data location that needs to be fixed(Database, Table, then Column). With phpmyadmin, I selected the database name, then the related table, and check on the field that needed the workaround. Edit that field DATA TYPE, to “Binary”. It is important that you make sure the LENGTH is maintained same. If the field’s data type was TEXT, MEDIUMTEXT, or LONGTEXT, change it to “BLOB”, with the original length.(This is to ensure that your data won’t get truncated). Collation here is not important since data is going to be converted to binary.

You should now see the field’s data type being changed to “binary”, “varbinary”, or “blob” depending on the length. Now the second step is, change the data type back to what it was before the binary conversion. Note that, a correct “Collation” must be set this time. For my case I’m sure the data is in UTF-8, so I’d use “utf8_general_ci” for the collation. After making this conversion, the data that contains chinese characters is displayed flawlessly on the new site. It’s just that easy.

And it really is that easy...except for the fact that I have to do this to each and every text input field in the db...yikes.












Post Your Comments (scroll down). Jump back to archived comments or the top.


* The Filing Cabinet *


2007EuropeTrip  2008EuropeTrip  4815162342  AdobeIllustrator  AdobePhotoshop  AdobePremiere  AJAX  Amazon  Amtrak  Apple  AroundTown  ArtDesignPhoto  ASP.net  Backup  Berkeley  BlackFriday  Bloglines  BlogTech  Books  Buddhishm  Business  Camping  China  China2004  Cinema  Commute  CoolTechnology  CSS  Culture  Customers  DailyLife  DeepInCode  Diabetes  DIY  Drupal  EastBay  Education  Email  Energy  Entertainment  EVDO  ExcelTips  F'edUpToys  FamilyandFriends  Fashion  FireFox  Flickr  FoodandDrink  Fraud  FreeStuff  Fun  Gallery  Games  Google  GoogleDocs  Halloween  Hardware  Hawkers  HipsterPDA  HomeStuff  HongyunArt  HuntingBeauty  InfoViz  InterestingWebsites  InTheNews  iPhone  iPod  iTunes  Japanese  Javascript  Lego  LifeHacks  LinkedMe  Linux  LongTail  Mambo  Mapping  MBA  Microsoft  MobilePhones  MoneyMoneyMoney  MovableType  MSNSearch  MSNSpaces  MusicFromCommercials  Nintendo  OfTheDay  OpenOffice  OpenSource  Organizing  Origami  Outdoors  Outlook  Paypal  Phishing  PlugIn  Poker  Politics  PPC6700  PreFab  PSP  PVR  Rabbits  reBlog  ReverieSoundRevue  Robots  Ruby  SanDisk  SanFrancisco  SanFranisco  SansaConnect  Science  Shoes  SiliconValley  SiteUpdates  SmallWorld  Society  Sony  Spam  Spoof  SQL  StarWars  Stupid  Sustainable  Sustainale  TestDrivenDevelopment  Thailand  Thailand2003-2004  Thanksgiving  Travel  Tshirts  Tutorial  Ubuntu  Vista  VisualStudio  Vlog  VroomVroom  WebDesign  Wii  Wiki  Windows  WindowsLive  Wireless  Xbox  Yahoo  YouTube  ZING  Zune