June 28th, 2010
I just spent a ton of time figuring this out, so I figured I’d toss it up on the blog in case someone else needs it.
Problem: I was exporting and manipulating the data in a MySQL database using the ruby mysql gem. Unfortunately, the people writing the data in the database were using curly quotes and other typographic marks that were causing trouble.
Solution:
require ‘rubygems’
require ‘mysql’
@dbh = Mysql.init
@dbh.options(Mysql::SET_CHARSET_NAME, ‘utf8′)
@dbh.real_connect(”localhost”,@dbuser,@dbpass,@dbname)
The key is to add a line in the options call to set the character set to UTF-8. This seems to solve the problem.
Hope this helps!
Posted in Ruby | No Comments »
April 15th, 2010
Posted in Uncategorized | No Comments »
February 8th, 2010
Posted in Meta | No Comments »
January 29th, 2010
Posted in Serendeputy | No Comments »
November 19th, 2009
Posted in Meta, Serendeputy | No Comments »
November 9th, 2009
Posted in Serendeputy | No Comments »
August 27th, 2009
Posted in Linky Goodness | No Comments »
August 17th, 2009
Posted in Linky Goodness | No Comments »
August 14th, 2009
Posted in Linky Goodness | No Comments »
July 28th, 2009
Posted in Business | No Comments »
July 27th, 2009
Posted in Linky Goodness | No Comments »
July 15th, 2009
Posted in Serendeputy | No Comments »
July 3rd, 2009
Posted in Uncategorized, Meta | No Comments »
July 2nd, 2009
Posted in Meta | No Comments »
June 30th, 2009
Posted in Programming | 1 Comment »
June 25th, 2009
Posted in Web, Personalization | No Comments »
June 16th, 2009
Posted in Meta | 2 Comments »
June 16th, 2009
Posted in Serendeputy | No Comments »
May 29th, 2009
Posted in Programming, Emacs | No Comments »
May 26th, 2009
Posted in Serendeputy | No Comments »
May 26th, 2009
Posted in Serendeputy | No Comments »
May 4th, 2009
Posted in Business | 1 Comment »
April 29th, 2009
Posted in Linky Goodness | No Comments »
April 14th, 2009
Posted in Web, Programming, Ruby | 2 Comments »
January 28th, 2009
Posted in Web, Fan Mail, SEO | No Comments »
January 27th, 2009
Posted in Serendeputy | No Comments »
January 14th, 2009
Posted in Web | No Comments »
January 5th, 2009
Posted in Web, Serendeputy | No Comments »
December 12th, 2008
Posted in Web | No Comments »
November 19th, 2008
Posted in Serendeputy | No Comments »
October 22nd, 2008
Posted in Web | No Comments »
October 20th, 2008
Posted in Web | No Comments »
September 26th, 2008
Posted in Programming | No Comments »
September 16th, 2008
Posted in Programming, Ruby | 1 Comment »
September 16th, 2008
Posted in Web, Fan Mail, Ruby | 1 Comment »
September 15th, 2008
Posted in Serendeputy | 1 Comment »
September 10th, 2008
Posted in Programming, Ruby | 1 Comment »
September 5th, 2008
Posted in Programming | No Comments »
August 25th, 2008
Posted in Programming | No Comments »
August 11th, 2008
Posted in Web, Fan Mail | No Comments »
July 7th, 2008
Posted in Linky Goodness | No Comments »
July 1st, 2008
Posted in Linky Goodness | No Comments »
June 27th, 2008
Posted in Fan Mail | 2 Comments »