commit a24436e68baff6cccda8f4f259375f14d2bd0f4c (HEAD, refs/remotes/origin/master, refs/remotes/origin/HEAD, refs/heads/master)
Author: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Date:   Wed Jan 25 03:07:26 2012 +0100

    Fix _escape when activesupport and fast_xs/hpricot are loaded.
    
    The to_xs method implemented by fast_xs (which is also used by hpricot)
    does not accept an encoding parameter, so rely on the original_xs in that
    context.

diff --git a/lib/builder/xmlbase.rb b/lib/builder/xmlbase.rb
index 0c9798f..06f8807 100644
--- a/lib/builder/xmlbase.rb
+++ b/lib/builder/xmlbase.rb
@@ -134,7 +134,12 @@ module Builder
       end
     else
       def _escape(text)
-        text.to_xs((@encoding != 'utf-8' or $KCODE != 'UTF8'))
+        # original_xs is defined by activesupport when fast_xs is
+        # loaded; since fast_xs (as of version 0.8.0) does not accept
+        # the encode parameter, use the original function if present.
+        toxs_method = ::String.method_defined?(:original_xs) ? :original_xs : :to_xs
+
+        text.send(toxs_method, (@encoding != 'utf-8' or $KCODE != 'UTF8'))
       end
     end
 
