diff --git a/lib/webrat/core/elements/link.rb b/lib/webrat/core/elements/link.rb
index <HASH>..<HASH> 100644
--- a/lib/webrat/core/elements/link.rb
+++ b/lib/webrat/core/elements/link.rb
@@ -53,7 +53,7 @@ module Webrat
     def authenticity_token
       return unless onclick && onclick.include?("s.setAttribute('name', 'authenticity_token');") &&
         onclick =~ /s\.setAttribute\('value', '([a-f0-9]{40})'\);/
-      $LAST_MATCH_INFO.captures.first
+      $~.captures.first
     end
 
     def onclick
diff --git a/lib/webrat/core/locators/link_locator.rb b/lib/webrat/core/locators/link_locator.rb
index <HASH>..<HASH> 100644
--- a/lib/webrat/core/locators/link_locator.rb
+++ b/lib/webrat/core/locators/link_locator.rb
@@ -45,7 +45,11 @@ module Webrat
       end
 
       def replace_nbsp(str)
-        str.gsub([0xA0].pack('U'), ' ')
+        if str.respond_to?(:force_encoding)
+          str.force_encoding('UTF-8').gsub(/\xc2\xa0/u, ' ')
+        else
+          str.gsub("\xc2\xa0", ' ')
+        end
       end
 
       def replace_nbsp_ref(str)
Don't use $LAST_MATCH_INFO since we don't require English.rb, use $~ instead