Raggle

Valid XHTML 1.1!

REXML::Encoding::ENCODING_CLAIMS Bug Workaround
Thursday, November 20 16:50:55 2003 EST

Problem:
Starting Raggle gives you the following error message:

./raggle:2744: uninitialized constant REXML::Encoding::ENCODING_CLAIMS (NameError)

Solution:
Make sure you're running Raggle version 0.2.4 or newer. If you're using a custom config file, edit it and look for the following lines:

    'Accept-Charset'      => if REXML::constants.include?('Encoding')
      (REXML::Encoding::ENCODING_CLAIMS.values.sort + ['*;q=0.1']).join(',')
    else
      'ISO-8859-1,UTF-8;q=0.7,*;q=0.7'
    end,

Replace the entire bit with this line:

    'Accept-Charset'      => 'ISO-8859-1,UTF-8;q=0.7,*;q=0.7',

And you should be up and running again. Read on for a description of what's happening

What's Going On?
REXML, the XML parser for Raggle, recently added a list of supported character encodings. I decided it would be nice to derive Raggle's list of supported character encodings from REXML. Older versions of REXML do not have a built-in list of supported character encodings. The code above checks for the existence of the REXML::Encoding namespace, and if it exists, then the list of supported character encodings is built from REXML::Encoding::ENCODING_CLAIMS. Unfortunately, newer versions of REXML define REXML::Encoding, but do not appear to have a built-in list of supported character encodings. The fix above merely falls back to a hard-coded list of supported encodings — the only safe thing to do until REXML provides a sane, consistent way of listing the supported character encodings.

Yes, I realize we could just check for REXML::Encoding, then check for REXML::Encoding::ENCODING_CLAIMS, but this two-tiered conditional would have to go either in the config file or in another custom method called by the config file (somewhat negating the benefit of having a simple keyword config system). More importantly, this approach feels like an over-engineered solution to a non-problem. With the line above, Raggle won't reject any particular encoding; it will just prefer ISO-8859-1 and UTF-8 over other encodings.