From d786e95a77939e1529314dc8c3e83e6a749715c5 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Mon, 4 Jan 2010 06:41:04 -0600 Subject: [PATCH] Ruby 1.9 + MySQL Hack The default encoding in MySQL is latin1. Ruby 1.9 is a stickler about the encoding of a sequence of bytes. In this case, a utf8 page name stored in the database comes back as "ASCII-8BIT" (ie, binary). Coerce that back to utf8. This doesn't affect SQLite3, and it doesn't affect Ruby 1.8. It doesn't even affect MySQL databases with "utf8" encoding (though that has other issues, since MySQL's utf8 support is broken). There are probably other, similar problems lurking. --- app/models/page.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/page.rb b/app/models/page.rb index e66e0415..e958ccfe 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -82,7 +82,7 @@ class Page < ActiveRecord::Base # Returns the original wiki-word name as separate words, so "MyPage" becomes "My Page". def plain_name - web.brackets_only? ? CGI.escapeHTML(name) : CGI.escapeHTML(WikiWords.separate(name)) + web.brackets_only? ? CGI.escapeHTML(name).as_utf8 : CGI.escapeHTML(WikiWords.separate(name)).as_utf8 end LOCKING_PERIOD = 30.minutes