aboutsummaryrefslogtreecommitdiffstats
path: root/lib/unicode_normalize
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unicode_normalize')
-rw-r--r--lib/unicode_normalize/normalize.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb
index 3075a56b50..22768f4c01 100644
--- a/lib/unicode_normalize/normalize.rb
+++ b/lib/unicode_normalize/normalize.rb
@@ -15,15 +15,15 @@ module UnicodeNormalize
REGEXP_K = Regexp.compile(REGEXP_K_STRING, Regexp::EXTENDED)
NF_HASH_D = Hash.new do |hash, key|
hash.delete hash.first[0] if hash.length>MAX_HASH_LENGTH # prevent DoS attack
- hash[key] = UnicodeNormalize.nfd_one(key)
+ hash[key] = nfd_one(key)
end
NF_HASH_C = Hash.new do |hash, key|
hash.delete hash.first[0] if hash.length>MAX_HASH_LENGTH # prevent DoS attack
- hash[key] = UnicodeNormalize.nfc_one(key)
+ hash[key] = nfc_one(key)
end
NF_HASH_K = Hash.new do |hash, key|
hash.delete hash.first[0] if hash.length>MAX_HASH_LENGTH # prevent DoS attack
- hash[key] = UnicodeNormalize.nfkd_one(key)
+ hash[key] = nfkd_one(key)
end
## Constants For Hangul
@@ -42,7 +42,7 @@ module UnicodeNormalize
Encoding::GB18030, Encoding::UCS_2BE, Encoding::UCS_4BE]
## Hangul Algorithm
- def UnicodeNormalize.hangul_decomp_one(target)
+ def self.hangul_decomp_one(target)
sIndex = target.ord - SBASE
return target if sIndex < 0 || sIndex >= SCOUNT
l = LBASE + sIndex / NCOUNT
@@ -51,7 +51,7 @@ module UnicodeNormalize
(t==TBASE ? [l, v] : [l, v, t]).pack('U*') + target[1..-1]
end
- def UnicodeNormalize.hangul_comp_one(string)
+ def self.hangul_comp_one(string)
length = string.length
if length>1 and 0 <= (lead =string[0].ord-LBASE) and lead < LCOUNT and
0 <= (vowel=string[1].ord-VBASE) and vowel < VCOUNT
@@ -67,7 +67,7 @@ module UnicodeNormalize
end
## Canonical Ordering
- def UnicodeNormalize.canonical_ordering_one(string)
+ def self.canonical_ordering_one(string)
sorting = string.each_char.collect { |c| [c, CLASS_TABLE[c]] }
(sorting.length-2).downto(0) do |i| # bubble sort
(0..i).each do |j|
@@ -81,7 +81,7 @@ module UnicodeNormalize
end
## Normalization Forms for Patterns (not whole Strings)
- def UnicodeNormalize.nfd_one(string)
+ def self.nfd_one(string)
string = string.dup
(0...string.length).each do |position|
if decomposition = DECOMPOSITION_TABLE[string[position]]
@@ -91,7 +91,7 @@ module UnicodeNormalize
canonical_ordering_one(hangul_decomp_one(string))
end
- def UnicodeNormalize.nfkd_one(string)
+ def self.nfkd_one(string)
string = string.dup
position = 0
while position < string.length
@@ -104,7 +104,7 @@ module UnicodeNormalize
string
end
- def UnicodeNormalize.nfc_one (string)
+ def self.nfc_one (string)
nfd_string = nfd_one string
start = nfd_string[0]
last_class = CLASS_TABLE[start]-1
@@ -121,7 +121,7 @@ module UnicodeNormalize
hangul_comp_one(start+accents)
end
- def UnicodeNormalize.normalize(string, form = :nfc)
+ def self.normalize(string, form = :nfc)
encoding = string.encoding
if encoding == Encoding::UTF_8
case form
@@ -143,7 +143,7 @@ module UnicodeNormalize
end
end
- def UnicodeNormalize.normalized?(string, form = :nfc)
+ def self.normalized?(string, form = :nfc)
encoding = string.encoding
if encoding == Encoding::UTF_8
case form