2014-10-18 21:04:10 -04:00
|
|
|
|
# coding: utf-8
|
|
|
|
|
|
2014-10-18 21:08:13 -04:00
|
|
|
|
# Copyright Ayumu Nojima (野島 歩) and Martin J. Dürst (duerst@it.aoyama.ac.jp)
|
2014-10-18 21:04:10 -04:00
|
|
|
|
|
2014-10-18 21:08:13 -04:00
|
|
|
|
require 'unicode_normalize/normalize.rb'
|
2014-10-18 21:04:10 -04:00
|
|
|
|
|
|
|
|
|
class String
|
2014-10-18 21:12:26 -04:00
|
|
|
|
def unicode_normalize(form = :nfc)
|
2014-10-18 21:10:12 -04:00
|
|
|
|
UnicodeNormalize.normalize(self, form)
|
2014-10-18 21:04:10 -04:00
|
|
|
|
end
|
|
|
|
|
|
2014-10-18 21:12:26 -04:00
|
|
|
|
def unicode_normalize!(form = :nfc)
|
2014-10-18 21:04:10 -04:00
|
|
|
|
replace(self.normalize(form))
|
|
|
|
|
end
|
|
|
|
|
|
2014-10-18 21:12:26 -04:00
|
|
|
|
def unicode_normalized?(form = :nfc)
|
2014-10-18 21:10:12 -04:00
|
|
|
|
UnicodeNormalize.normalized?(self, form)
|
2014-10-18 21:04:10 -04:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|