summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/unicode_normalize/normalize.rb12
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb
index 1511f75f8a..18080ce03d 100644
--- a/lib/unicode_normalize/normalize.rb
+++ b/lib/unicode_normalize/normalize.rb
@@ -21,10 +21,6 @@ module UnicodeNormalize
hash.shift if hash.length>MAX_HASH_LENGTH # prevent DoS attack
hash[key] = nfc_one(key)
end
- NF_HASH_K = Hash.new do |hash, key|
- hash.shift if hash.length>MAX_HASH_LENGTH # prevent DoS attack
- hash[key] = nfkd_one(key)
- end
## Constants For Hangul
# for details such as the meaning of the identifiers below, please see
@@ -88,10 +84,6 @@ module UnicodeNormalize
canonical_ordering_one(hangul_decomp_one(string))
end
- def self.nfkd_one(string)
- string.chars.map! {|c| KOMPATIBLE_TABLE[c] || c}.join('')
- end
-
def self.nfc_one(string)
nfd_string = nfd_one string
start = nfd_string[0]
@@ -119,9 +111,9 @@ module UnicodeNormalize
when :nfd then
string.gsub REGEXP_D, NF_HASH_D
when :nfkc then
- string.gsub(REGEXP_K, NF_HASH_K).gsub REGEXP_C, NF_HASH_C
+ string.gsub(REGEXP_K, KOMPATIBLE_TABLE).gsub(REGEXP_C, NF_HASH_C)
when :nfkd then
- string.gsub(REGEXP_K, NF_HASH_K).gsub REGEXP_D, NF_HASH_D
+ string.gsub(REGEXP_K, KOMPATIBLE_TABLE).gsub(REGEXP_D, NF_HASH_D)
else
raise ArgumentError, "Invalid normalization form #{form}."
end