From e4f71908d62d7e55a55888ad00dce25eb66a1dea Mon Sep 17 00:00:00 2001 From: duerst Date: Sun, 19 Oct 2014 01:04:10 +0000 Subject: lib/unicode_normalize.rb: Importing from https://github.com/duerst/eprun/blob/master/lib/string_normalize.rb. (removing trailing whitespace, fixing EOLs and adding EOL property) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/unicode_normalize.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/unicode_normalize.rb (limited to 'lib') diff --git a/lib/unicode_normalize.rb b/lib/unicode_normalize.rb new file mode 100644 index 0000000000..a1a1149d72 --- /dev/null +++ b/lib/unicode_normalize.rb @@ -0,0 +1,22 @@ +# coding: utf-8 + +# Copyright 2010-2013 Ayumu Nojima (野島 歩) and Martin J. Dürst (duerst@it.aoyama.ac.jp) +# available under the same licence as Ruby itself +# (see http://www.ruby-lang.org/en/LICENSE.txt) + +require File.dirname(__FILE__) + '/normalize' + +class String + def normalize(form = :nfc) + Normalize.normalize(self, form) + end + + def normalize!(form = :nfc) + replace(self.normalize(form)) + end + + def normalized?(form = :nfc) + Normalize.normalized?(self, form) + end +end + -- cgit v1.2.3