Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for $KCODE "UTF8" when used with Rails >= 2.2.0.

  • Loading branch information...
commit 0a629096b2de743142a0ef477c6561a98d5dcd5a 1 parent 46156f5
@thbar authored
View
5 History.txt
@@ -1,5 +1,8 @@
+== 1.0.2 / 2008-12-10
+ * Added support for $KCODE "UTF8" with Rails >= 2.2.0 (thanks to Thomas Brian and John Devine for their bug report)
+
== 1.0.1 / 2008-12-05
- * Added support for Rails > 2.2 (thanks Nicolas Fouché!)
+ * Added support for Rails >= 2.2.0 (thanks Nicolas Fouché!)
* Refactored to check ActiveSupport version
* Added missing require activerecord to the lib
View
9 lib/diacritics_fu.rb
@@ -1,8 +1,13 @@
require 'active_support'
require 'active_support/version'
+# hum - I love that kind of things
if ActiveSupport::VERSION::STRING >= "2.2.0"
- require File.dirname(__FILE__) + '/diacritics_fu/new_escaper'
+ if $KCODE == 'UTF8'
+ require File.dirname(__FILE__) + '/diacritics_fu/new_escaper_kcode_utf8'
+ else
+ require File.dirname(__FILE__) + '/diacritics_fu/new_escaper'
+ end
else
require File.dirname(__FILE__) + '/diacritics_fu/old_escaper'
-end
+end
View
5 lib/diacritics_fu/new_escaper_kcode_utf8.rb
@@ -0,0 +1,5 @@
+module DiacriticsFu
+ def self.escape(str)
+ ActiveSupport::Multibyte::Chars.new(str).normalize(:d).split(//u).reject { |e| e.wrapped_string[0] > 128 }.join
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.