Skip to content

Instantly share code, notes, and snippets.

@buzztaiki
Created June 8, 2012 16:32
Show Gist options
  • Select an option

  • Save buzztaiki/2896693 to your computer and use it in GitHub Desktop.

Select an option

Save buzztaiki/2896693 to your computer and use it in GitHub Desktop.
Patch for migemo on ruby 1.9 more
diff --git a/migemo-dict.rb b/migemo-dict.rb
index 61f60ad..e44e6d1 100644
--- a/migemo-dict.rb
+++ b/migemo-dict.rb
@@ -33,8 +33,14 @@ class MigemoDictItem
end
class MigemoDict
+ class << self
+ def open(filename)
+ File.open(filename, 'r', :external_encoding => __ENCODING__)
+ end
+ end
+
def initialize (filename)
- @dict = File.new(filename)
+ @dict = MigemoDict.open(filename)
end
private
@@ -57,7 +63,7 @@ end
class MigemoStaticDict < MigemoDict
def initialize (filename)
super(filename)
- @index = File.new(filename + ".idx").read.unpack "N*"
+ @index = MigemoDict.open(filename + ".idx").read.unpack "N*"
end
private
@@ -106,8 +112,8 @@ end
class MigemoDictCache
def initialize (filename)
- @dict = File.new(filename)
- @index = File.new(filename + ".idx").read.unpack "N*"
+ @dict = MigemoDict.open(filename)
+ @index = MigemoDict.open(filename + ".idx").read.unpack "N*"
end
def decompose (idx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment