Rails 2.3 + Ruby 1.8 UTF-8 Hack

I work on a project which is currently still locked in Rails 2.3 running on Ruby 1.8 – of course, as years have gone by, more and more support for internationalization has come up, and now with emojis being part of the UTF-8 standard, and people people trying to use them in blog posts and comments and the like, I obviously encounter the fiasco that is trying to have Ruby on Rails on MySQL deal with this.

It’s been a mess.

In the end, I’ve just opted for a hack on the String class which gets used at the point that the model’s properties are assigned:

class String

  # Converts multi-byte characters which use more than 2 bytes into HTML entities
  def to_multibyte_html_entities
    each_char.map { |c| c.bytes.count > 2 ? "&#x#{c.multibyte_ord.to_s(16)};" : c }.join
  # Identical to #ord but properly supporting multibyte, like later versions
  # of Ruby
  def multibyte_ord


CM3 v5.10 on Ubuntu

This was a fairly difficult task to figure out (no documentation out there), so I thought I’d share how I ended up getting the latest version of the Critical Mass Modula-3 compiler installed.

Please note that I was working an an emulated 32-bit operating system, so if you’re working on a 64-bit installation, make changes where applicable.

  1. You must first download an actual binary copy of CM3. This isn’t actively mentioned anywhere in the source documentation, but you will notice that as you try to do any of the scripts, you will always fail before anything else happens. If you pay close attention, you will see the script is trying to run “cm3” … which is annoying, because it’s CM3 you’re trying to install :PGo to the URL https://modula3.elegosoft.com/cm3/ and scroll down to the section “Target Platform LINUXLIBC6”. I just downloaded the first file, so it’s the whole shebang.
  2. Extract the file and run “cminstall” – this will install the cm3 compiler in a place you wouldn’t necessary expect: /usr/local/cm3/bin – this means you won’t be able to invoke cm3 right away, so you must …
  3. Add the cm3 binary directory to the path thus:
  4. Next, clone the latest source respository:
  5. From the directory cm3/scripts, run the upgrade.sh script

And presto – your CM3 should now be upgraded all the way.


When trying to build all the additional packages (using “do-cm3-all.sh buildship“), even if you have ODBC drivers installed, the process will fail when building the “db” packages. To fix this:

This holds true for the UI package, as well, specifically lixXaw and libXmu: